--- gigedit/trunk/src/gigedit/mainwindow.cpp 2020/09/26 18:49:20 3825 +++ gigedit/trunk/src/gigedit/mainwindow.cpp 2020/10/06 16:45:17 3826 @@ -5063,28 +5063,7 @@ if (!file) return; // collect all samples that are not referenced by any instrument - std::list lsamples; - for (int iSample = 0; file->GetSample(iSample); ++iSample) { - gig::Sample* sample = file->GetSample(iSample); - bool isUsed = false; - for (gig::Instrument* instrument = file->GetFirstInstrument(); instrument; - instrument = file->GetNextInstrument()) - { - for (gig::Region* rgn = instrument->GetFirstRegion(); rgn; - rgn = instrument->GetNextRegion()) - { - for (int i = 0; i < 256; ++i) { - if (!rgn->pDimensionRegions[i]) continue; - if (rgn->pDimensionRegions[i]->pSample != sample) continue; - isUsed = true; - goto endOfRefSearch; - } - } - } - endOfRefSearch: - if (!isUsed) lsamples.push_back(sample); - } - + std::list lsamples = unusedSamples(file); if (lsamples.empty()) return; // notify everybody that we're going to remove these samples