From b2d338c2ee26a05f65e4b6ef547dc9791b3369cb Mon Sep 17 00:00:00 2001 From: Franz Trischberger Date: Wed, 9 Oct 2019 14:04:59 +0300 Subject: [PATCH] fixup: previous commit f*** up the group=manual logic. --- src/Launcher.cpp | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/Launcher.cpp b/src/Launcher.cpp index e6511b2..2d944af 100644 --- a/src/Launcher.cpp +++ b/src/Launcher.cpp @@ -75,15 +75,26 @@ struct CoutProgressIndicator : public ProgressIndicator { std::list Launcher::getBracketedSets() const { std::list result; if (generalOptions.grouping == LoadOptions::Grouping::MANUAL) { - QStringList fileNames = generalOptions.fileNames; - while(!fileNames.empty()) { - LoadOptions opt = generalOptions; - auto oIt = opt.fileNames.begin(); - auto goIt = fileNames.begin(); - std::advance(oIt, generalOptions.imagesPerBracket); - std::advance(goIt, generalOptions.imagesPerBracket); - opt.fileNames.erase(oIt, opt.fileNames.end()); - fileNames.erase(fileNames.begin(), goIt); + LoadOptions globalOptions = generalOptions; + while(!globalOptions.fileNames.empty()) { + LoadOptions opt = globalOptions; + + // opt.fileNames and globalOptions.fileNames are equal + // *optIt == *globaloptIt + auto optIt = opt.fileNames.begin(); + auto globaloptIt = globalOptions.fileNames.begin(); + + // move both iterators by the number of images per bracket + std::advance(optIt, globalOptions.imagesPerBracket); + std::advance(globaloptIt, globalOptions.imagesPerBracket); + + // we want to keep only the first imagesPerBracket file names + // erase the tail + opt.fileNames.erase(optIt, opt.fileNames.end()); + + // the first imagesPerBracket file names found their new home in opt + // Erase them from globalOptions + globalOptions.fileNames.erase(globalOptions.fileNames.begin(), globaloptIt); result.push_back(opt); } } else {