diff --git a/es-app/src/MiximageGenerator.cpp b/es-app/src/MiximageGenerator.cpp index 0dbbc760a..648e2d9e3 100644 --- a/es-app/src/MiximageGenerator.cpp +++ b/es-app/src/MiximageGenerator.cpp @@ -4,7 +4,7 @@ // MiximageGenerator.cpp // // Generates miximages from screenshots, marquees and 3D box/cover images. -// Called from GuiScraperSearch. +// Called from GuiScraperSearch and GuiOfflineGenerator. // #include "MiximageGenerator.h" @@ -17,9 +17,8 @@ #include -MiximageGenerator::MiximageGenerator(FileData* game, bool& result, std::string& resultMessage) +MiximageGenerator::MiximageGenerator(FileData* game, std::string& resultMessage) : mGame(game), - mResult(result), mResultMessage(resultMessage), mWidth(1280), mHeight(960), @@ -43,7 +42,6 @@ void MiximageGenerator::startThread(std::promise* miximagePromise) if (mGame->getMiximagePath() != "" && !Settings::getInstance()->getBool("MiximageOverwrite")) { LOG(LogDebug) << "MiximageGenerator::MiximageGenerator(): File already exists and miximage " "overwriting has not been enabled, aborting"; - mResult = true; mMiximagePromise->set_value(true); return; } @@ -52,7 +50,6 @@ void MiximageGenerator::startThread(std::promise* miximagePromise) LOG(LogDebug) << "MiximageGenerator::MiximageGenerator(): " "No screenshot image found, aborting"; mResultMessage = "No screenshot image found, couldn't generate miximage"; - mResult = true; mMiximagePromise->set_value(true); return; } @@ -89,7 +86,9 @@ void MiximageGenerator::startThread(std::promise* miximagePromise) if (generateImage()) { LOG(LogError) << "Failed to generate miximage"; - mResult = true; + mMiximagePromise->set_value(true); + mResultMessage = mMessage; + return; } else { const auto endTime = std::chrono::system_clock::now(); @@ -99,7 +98,6 @@ void MiximageGenerator::startThread(std::promise* miximagePromise) (endTime - startTime).count() << " ms"; } - mResult = false; mResultMessage = mMessage; mMiximagePromise->set_value(false); } diff --git a/es-app/src/MiximageGenerator.h b/es-app/src/MiximageGenerator.h index 472b9884b..bb6f2093a 100644 --- a/es-app/src/MiximageGenerator.h +++ b/es-app/src/MiximageGenerator.h @@ -4,7 +4,7 @@ // MiximageGenerator.h // // Generates miximages from screenshots, marquees and 3D box/cover images. -// Called from GuiScraperSearch. +// Called from GuiScraperSearch and GuiOfflineGenerator. // #ifndef ES_APP_SCRAPERS_MIXIMAGE_GENERATOR_H @@ -25,7 +25,7 @@ using namespace cimg_library; class MiximageGenerator { public: - MiximageGenerator(FileData* game, bool& result, std::string& resultMessage); + MiximageGenerator(FileData* game, std::string& resultMessage); ~MiximageGenerator(); void startThread(std::promise* miximagePromise); @@ -44,10 +44,8 @@ private: std::string getSavePath(); FileData* mGame; - bool& mResult; std::string& mResultMessage; std::string mMessage; - std::promise* mMiximagePromise; std::string mScreenshotPath; diff --git a/es-app/src/guis/GuiScraperSearch.cpp b/es-app/src/guis/GuiScraperSearch.cpp index 91852befc..2e8e23ad2 100644 --- a/es-app/src/guis/GuiScraperSearch.cpp +++ b/es-app/src/guis/GuiScraperSearch.cpp @@ -667,7 +667,7 @@ void GuiScraperSearch::update(int deltaTime) mMDResolveHandle.reset(); // We always let the miximage generator thread complete. mMiximageGeneratorThread.join(); - if (!mMiximageResult) + if (!mGeneratorFuture.get()) mScrapeResult.savedNewMedia = true; returnResult(mScrapeResult); mMiximageGenerator.reset(); @@ -687,7 +687,7 @@ void GuiScraperSearch::update(int deltaTime) Settings::getInstance()->getBool("MiximageOverwrite"))) { mMiximageGenerator = std::make_unique(mLastSearch.game, - mMiximageResult, mResultMessage); + mResultMessage); // The promise/future mechanism is used as signaling for the thread to // indicate that processing has been completed. The reason to run a separate