From dc3731660be169ff0fb424315e52c84ca0ccca0a Mon Sep 17 00:00:00 2001 From: Leon Styhre <leon@leonstyhre.com> Date: Mon, 1 Feb 2021 18:52:49 +0100 Subject: [PATCH] Fixed an issue where the gamelist entry would not update properly if the user aborted the single-game scraper. --- es-app/src/guis/GuiGameScraper.cpp | 21 ++++++++++++++++++++- es-app/src/guis/GuiScraperSearch.h | 2 ++ es-app/src/scrapers/Scraper.h | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/es-app/src/guis/GuiGameScraper.cpp b/es-app/src/guis/GuiGameScraper.cpp index f09528c05..e32ea054d 100644 --- a/es-app/src/guis/GuiGameScraper.cpp +++ b/es-app/src/guis/GuiGameScraper.cpp @@ -76,7 +76,17 @@ GuiGameScraper::GuiGameScraper( mGrid.resetCursor(); })); buttons.push_back(std::make_shared<ButtonComponent>( - mWindow, "CANCEL", "cancel", [&] { delete this; })); + mWindow, "CANCEL", "cancel", [&] { + if (mSearch->getSavedNewMedia()) { + // If the user aborted the scraping but there was still some media downloaded, + // then force an unload of the textures for the game image and marquee, and make + // an update of the game entry. Otherwise the images would not get updated until + // the user scrolls up and down the gamelist. + TextureResource::manualUnload(mSearchParams.game->getImagePath(), false); + TextureResource::manualUnload(mSearchParams.game->getMarqueePath(), false); + ViewController::get()->onFileChanged(mSearchParams.game, true); + } + delete this; })); mButtonGrid = makeButtonGrid(mWindow, buttons); mGrid.setEntry(mButtonGrid, Vector2i(0, 6), true, false); @@ -134,6 +144,15 @@ void GuiGameScraper::onSizeChanged() bool GuiGameScraper::input(InputConfig* config, Input input) { if (config->isMappedTo("b", input) && input.value) { + if (mSearch->getSavedNewMedia()) { + // If the user aborted the scraping but there was still some media downloaded, + // then force an unload of the textures for the game image and marquee, and make + // an update of the game entry. Otherwise the images would not get updated until + // the user scrolls up and down the gamelist. + TextureResource::manualUnload(mSearchParams.game->getImagePath(), false); + TextureResource::manualUnload(mSearchParams.game->getMarqueePath(), false); + ViewController::get()->onFileChanged(mSearchParams.game, true); + } delete this; return true; } diff --git a/es-app/src/guis/GuiScraperSearch.h b/es-app/src/guis/GuiScraperSearch.h index 88319a9e2..c5e280662 100644 --- a/es-app/src/guis/GuiScraperSearch.h +++ b/es-app/src/guis/GuiScraperSearch.h @@ -44,6 +44,8 @@ public: void openInputScreen(ScraperSearchParams& from); void stop(); inline SearchType getSearchType() const { return mSearchType; } + bool getSavedNewMedia() + { return (mMDResolveHandle ? mMDResolveHandle->getSavedNewMedia() : false); }; static bool saveMetadata(const ScraperSearchResult& result, MetaDataList& metadata, FileData* scrapedGame); diff --git a/es-app/src/scrapers/Scraper.h b/es-app/src/scrapers/Scraper.h index d6c65bd15..77ab0b7b1 100644 --- a/es-app/src/scrapers/Scraper.h +++ b/es-app/src/scrapers/Scraper.h @@ -179,6 +179,7 @@ public: void update() override; inline const ScraperSearchResult& getResult() const { assert(mStatus == ASYNC_DONE); return mResult; } + bool getSavedNewMedia() { return mResult.savedNewMedia; } private: ScraperSearchResult mResult;