Fixed an issue where the gamelist would not always display newly generated miximages.

Also changed some MiximageGenerator error message from uppercase to lowercase.
This commit is contained in:
Leon Styhre 2021-06-08 21:07:35 +02:00
parent e25c43a6cc
commit 4fde0e72d1
2 changed files with 14 additions and 9 deletions

View file

@ -43,6 +43,7 @@ void MiximageGenerator::startThread(std::promise<bool>* miximagePromise)
if (mGame->getMiximagePath() != "" && !Settings::getInstance()->getBool("MiximageOverwrite")) { if (mGame->getMiximagePath() != "" && !Settings::getInstance()->getBool("MiximageOverwrite")) {
LOG(LogDebug) << "MiximageGenerator::MiximageGenerator(): File already exists and miximage " LOG(LogDebug) << "MiximageGenerator::MiximageGenerator(): File already exists and miximage "
"overwriting has not been enabled, aborting"; "overwriting has not been enabled, aborting";
mResult = true;
mMiximagePromise->set_value(true); mMiximagePromise->set_value(true);
return; return;
} }
@ -50,7 +51,8 @@ void MiximageGenerator::startThread(std::promise<bool>* miximagePromise)
if ((mScreenshotPath = mGame->getScreenshotPath()) == "") { if ((mScreenshotPath = mGame->getScreenshotPath()) == "") {
LOG(LogDebug) << "MiximageGenerator::MiximageGenerator(): " LOG(LogDebug) << "MiximageGenerator::MiximageGenerator(): "
"No screenshot image found, aborting"; "No screenshot image found, aborting";
mResultMessage = "NO SCREENSHOT IMAGE FOUND, COULDN'T GENERATE MIXIMAGE"; mResultMessage = "No screenshot image found, couldn't generate miximage";
mResult = true;
mMiximagePromise->set_value(true); mMiximagePromise->set_value(true);
return; return;
} }
@ -97,6 +99,7 @@ void MiximageGenerator::startThread(std::promise<bool>* miximagePromise)
(endTime - startTime).count() << " ms"; (endTime - startTime).count() << " ms";
} }
mResult = false;
mResultMessage = mMessage; mResultMessage = mMessage;
mMiximagePromise->set_value(false); mMiximagePromise->set_value(false);
} }
@ -128,7 +131,7 @@ bool MiximageGenerator::generateImage()
if (fileFormat == FIF_UNKNOWN) { if (fileFormat == FIF_UNKNOWN) {
LOG(LogError) << "Screenshot image in unknown image format, aborting"; LOG(LogError) << "Screenshot image in unknown image format, aborting";
mMessage = "SCREENSHOT IMAGE IN UNKNOWN FORMAT, COULDN'T GENERATE MIXIMAGE"; mMessage = "Screenshot image in unknown format, couldn't generate miximage";
return true; return true;
} }
@ -143,13 +146,13 @@ bool MiximageGenerator::generateImage()
} }
else { else {
LOG(LogError) << "Screenshot file format not supported"; LOG(LogError) << "Screenshot file format not supported";
mMessage = "SCREENSHOT IMAGE IN UNSUPPORTED FORMAT, COULDN'T GENERATE MIXIMAGE"; mMessage = "Screenshot image in unsupported format, couldn't generate miximage";
return true; return true;
} }
if (!screenshotFile) { if (!screenshotFile) {
LOG(LogError) << "Error loading screenshot image, corrupt file?"; LOG(LogError) << "Error loading screenshot image, corrupt file?";
mMessage = "ERROR LOADING SCREENSHOT IMAGE, COULDN'T GENERATE MIXIMAGE"; mMessage = "Error loading screenshot image, couldn't generate miximage";
return true; return true;
} }
@ -187,7 +190,7 @@ bool MiximageGenerator::generateImage()
#endif #endif
if (!marqueeFile) { if (!marqueeFile) {
LOG(LogError) << "Couldn't load marquee image, corrupt file?"; LOG(LogError) << "Couldn't load marquee image, corrupt file?";
mMessage = "ERROR LOADING MARQUEE IMAGE, CORRUPT FILE?"; mMessage = "Error loading marquee image, corrupt file?";
mMarquee = false; mMarquee = false;
} }
} }
@ -226,7 +229,7 @@ bool MiximageGenerator::generateImage()
#endif #endif
if (!boxFile) { if (!boxFile) {
LOG(LogError) << "Couldn't load 3D box image, corrupt file?"; LOG(LogError) << "Couldn't load 3D box image, corrupt file?";
mMessage = "ERROR LOADING 3D BOX IMAGE, CORRUPT FILE?"; mMessage = "Error loading 3d box image, corrupt file?";
mBox3D = false; mBox3D = false;
} }
} }
@ -265,7 +268,7 @@ bool MiximageGenerator::generateImage()
#endif #endif
if (!boxFile) { if (!boxFile) {
LOG(LogError) << "Couldn't load box cover image, corrupt file?"; LOG(LogError) << "Couldn't load box cover image, corrupt file?";
mMessage = "ERROR LOADING BOX COVER IMAGE, CORRUPT FILE?"; mMessage = "Error loading box cover image, corrupt file?";
mCover = false; mCover = false;
} }
} }

View file

@ -318,6 +318,7 @@ void GuiScraperSearch::updateViewStyle()
void GuiScraperSearch::search(const ScraperSearchParams& params) void GuiScraperSearch::search(const ScraperSearchParams& params)
{ {
mBlockAccept = true; mBlockAccept = true;
mMiximageResult = false;
mScrapeResult = {}; mScrapeResult = {};
mResultList->clear(); mResultList->clear();
@ -339,6 +340,7 @@ void GuiScraperSearch::stop()
mMDRetrieveURLsHandle.reset(); mMDRetrieveURLsHandle.reset();
mMiximageGenerator.reset(); mMiximageGenerator.reset();
mBlockAccept = false; mBlockAccept = false;
mMiximageResult = false;
mScrapeResult = {}; mScrapeResult = {};
} }
@ -663,11 +665,11 @@ void GuiScraperSearch::update(int deltaTime)
// Only wait one millisecond, this update() function runs very frequently. // Only wait one millisecond, this update() function runs very frequently.
if (mGeneratorFuture.wait_for(std::chrono::milliseconds(1)) == std::future_status::ready) { if (mGeneratorFuture.wait_for(std::chrono::milliseconds(1)) == std::future_status::ready) {
mMDResolveHandle.reset(); mMDResolveHandle.reset();
// We always let the miximage generator thread complete.
mMiximageGeneratorThread.join();
if (!mMiximageResult) if (!mMiximageResult)
mScrapeResult.savedNewMedia = true; mScrapeResult.savedNewMedia = true;
returnResult(mScrapeResult); returnResult(mScrapeResult);
// We always let the miximage generator thread complete.
mMiximageGeneratorThread.join();
mMiximageGenerator.reset(); mMiximageGenerator.reset();
} }
} }