mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-02-16 20:15:38 +00:00
Fixed a crash that could occur when aborting the single-scraper followed by a re-scrape.
This commit is contained in:
parent
c470abf2da
commit
654dc2a546
|
@ -19,13 +19,15 @@
|
||||||
#include "views/ViewController.h"
|
#include "views/ViewController.h"
|
||||||
|
|
||||||
GuiGameScraper::GuiGameScraper(Window* window,
|
GuiGameScraper::GuiGameScraper(Window* window,
|
||||||
ScraperSearchParams params,
|
ScraperSearchParams& params,
|
||||||
std::function<void(const ScraperSearchResult&)> doneFunc)
|
std::function<void(const ScraperSearchResult&)> doneFunc,
|
||||||
|
bool& savedMediaAndAborted)
|
||||||
: GuiComponent(window)
|
: GuiComponent(window)
|
||||||
, mClose(false)
|
, mClose(false)
|
||||||
, mGrid(window, glm::ivec2{2, 6})
|
, mGrid(window, glm::ivec2{2, 6})
|
||||||
, mBox(window, ":/graphics/frame.svg")
|
, mBox(window, ":/graphics/frame.svg")
|
||||||
, mSearchParams(params)
|
, mSearchParams(params)
|
||||||
|
, mSavedMediaAndAborted(savedMediaAndAborted)
|
||||||
{
|
{
|
||||||
addChild(&mBox);
|
addChild(&mBox);
|
||||||
addChild(&mGrid);
|
addChild(&mGrid);
|
||||||
|
@ -169,12 +171,10 @@ bool GuiGameScraper::input(InputConfig* config, Input input)
|
||||||
if (config->isMappedTo("b", input) && input.value) {
|
if (config->isMappedTo("b", input) && input.value) {
|
||||||
if (mSearch->getSavedNewMedia()) {
|
if (mSearch->getSavedNewMedia()) {
|
||||||
// If the user aborted the scraping but there was still some media downloaded,
|
// 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
|
// then flag to GuiMetaDataEd that the image and marquee textures need to be
|
||||||
// an update of the game entry. Otherwise the images would not get updated until
|
// manually unloaded and that the gamelist needs to be reloaded. Otherwise the
|
||||||
// the user scrolls up and down the gamelist.
|
// images would not get updated until the user scrolls up and down the gamelist.
|
||||||
TextureResource::manualUnload(mSearchParams.game->getImagePath(), false);
|
mSavedMediaAndAborted = true;
|
||||||
TextureResource::manualUnload(mSearchParams.game->getMarqueePath(), false);
|
|
||||||
ViewController::get()->onFileChanged(mSearchParams.game, true);
|
|
||||||
}
|
}
|
||||||
delete this;
|
delete this;
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -20,8 +20,9 @@ class GuiGameScraper : public GuiComponent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GuiGameScraper(Window* window,
|
GuiGameScraper(Window* window,
|
||||||
ScraperSearchParams params,
|
ScraperSearchParams& params,
|
||||||
std::function<void(const ScraperSearchResult&)> doneFunc);
|
std::function<void(const ScraperSearchResult&)> doneFunc,
|
||||||
|
bool& savedMediaAndAborted);
|
||||||
|
|
||||||
void onSizeChanged() override;
|
void onSizeChanged() override;
|
||||||
|
|
||||||
|
@ -48,6 +49,7 @@ private:
|
||||||
std::shared_ptr<ComponentList> mResultList;
|
std::shared_ptr<ComponentList> mResultList;
|
||||||
|
|
||||||
ScraperSearchParams mSearchParams;
|
ScraperSearchParams mSearchParams;
|
||||||
|
bool& mSavedMediaAndAborted;
|
||||||
|
|
||||||
std::function<void()> mCancelFunc;
|
std::function<void()> mCancelFunc;
|
||||||
};
|
};
|
||||||
|
|
|
@ -52,6 +52,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
|
||||||
, mClearGameFunc{clearGameFunc}
|
, mClearGameFunc{clearGameFunc}
|
||||||
, mDeleteGameFunc{deleteGameFunc}
|
, mDeleteGameFunc{deleteGameFunc}
|
||||||
, mMediaFilesUpdated{false}
|
, mMediaFilesUpdated{false}
|
||||||
|
, mSavedMediaAndAborted{false}
|
||||||
, mInvalidEmulatorEntry{false}
|
, mInvalidEmulatorEntry{false}
|
||||||
{
|
{
|
||||||
mControllerBadges = BadgeComponent::getGameControllers();
|
mControllerBadges = BadgeComponent::getGameControllers();
|
||||||
|
@ -719,7 +720,8 @@ void GuiMetaDataEd::save()
|
||||||
void GuiMetaDataEd::fetch()
|
void GuiMetaDataEd::fetch()
|
||||||
{
|
{
|
||||||
GuiGameScraper* scr = new GuiGameScraper(
|
GuiGameScraper* scr = new GuiGameScraper(
|
||||||
mWindow, mScraperParams, std::bind(&GuiMetaDataEd::fetchDone, this, std::placeholders::_1));
|
mWindow, mScraperParams, std::bind(&GuiMetaDataEd::fetchDone, this, std::placeholders::_1),
|
||||||
|
mSavedMediaAndAborted);
|
||||||
mWindow->pushGui(scr);
|
mWindow->pushGui(scr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -791,11 +793,11 @@ void GuiMetaDataEd::close()
|
||||||
|
|
||||||
std::function<void()> closeFunc;
|
std::function<void()> closeFunc;
|
||||||
closeFunc = [this] {
|
closeFunc = [this] {
|
||||||
if (mMediaFilesUpdated) {
|
if (mMediaFilesUpdated || mSavedMediaAndAborted) {
|
||||||
// Always reload the gamelist if media files were updated, even if the user
|
// Always reload the gamelist if media files were updated, even if the user
|
||||||
// chose to not save any metadata changes. Also manually unload the game image
|
// chose to not save any metadata changes or aborted the scraping. Also manually
|
||||||
// and marquee, as otherwise they would not get updated until the user scrolls up
|
// unload the game image and marquee, as otherwise they would not get updated
|
||||||
// and down the gamelist.
|
// until the user scrolls up and down the gamelist.
|
||||||
TextureResource::manualUnload(mScraperParams.game->getImagePath(), false);
|
TextureResource::manualUnload(mScraperParams.game->getImagePath(), false);
|
||||||
TextureResource::manualUnload(mScraperParams.game->getMarqueePath(), false);
|
TextureResource::manualUnload(mScraperParams.game->getMarqueePath(), false);
|
||||||
ViewController::get()->reloadGameListView(mScraperParams.system);
|
ViewController::get()->reloadGameListView(mScraperParams.system);
|
||||||
|
|
|
@ -71,6 +71,7 @@ private:
|
||||||
std::function<void()> mDeleteGameFunc;
|
std::function<void()> mDeleteGameFunc;
|
||||||
|
|
||||||
bool mMediaFilesUpdated;
|
bool mMediaFilesUpdated;
|
||||||
|
bool mSavedMediaAndAborted;
|
||||||
bool mInvalidEmulatorEntry;
|
bool mInvalidEmulatorEntry;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue