From bfe591ffaf859b3b1a2ec4708297687d1555d6dc Mon Sep 17 00:00:00 2001 From: Peter Swimm Date: Sun, 18 Oct 2026 17:15:26 -0700 Subject: [PATCH] Fix SamplePool::Reassign reporting a loaded print as failed Reassign treated loadSample's result as a bool, but loadSample returns SLOAD_OK, which is 0, on success. So every print that loaded returned -1, and FxPrinter::Run assigned that -1 to the instrument while saying "OK!": the instrument was left without its printed sample. It also unloaded the old copy whenever the file was already on disk, even when that file was not in the pool, which called unload(-1). Now it unloads only a sample the pool holds. Assisted-by: Claude (LLM) --- sources/Application/Instruments/SamplePool.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sources/Application/Instruments/SamplePool.cpp b/sources/Application/Instruments/SamplePool.cpp index e8fb931e..874dc5d5 100644 --- a/sources/Application/Instruments/SamplePool.cpp +++ b/sources/Application/Instruments/SamplePool.cpp @@ -253,14 +253,15 @@ int SamplePool::Reassign(std::string name, bool imported) { if (count_ == MAX_PIG_SAMPLES) return -1; int insertedIndex = getIndexOf(name.c_str()); - if (imported) + // on disk is not always in the pool: unload only what is + if (imported && insertedIndex >= 0) unload(insertedIndex); std::string aliasPath = "samples:"; aliasPath += name; Path dstPath(aliasPath.c_str()); - if (loadSample(dstPath.GetCanonicalPath().c_str())) { + if (loadSample(dstPath.GetCanonicalPath().c_str()) == SLOAD_OK) { SetChanged(); SamplePoolEvent ev; ev.index_ = getIndexOf(name.c_str());;