mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 14:15:38 +00:00
Fixed an issue where attempting to refine or skip a scraper search could lead to a crash.
This commit is contained in:
parent
122b9b2374
commit
abbc3384fd
|
@ -72,8 +72,11 @@ GuiGameScraper::GuiGameScraper(Window* window,
|
|||
|
||||
buttons.push_back(
|
||||
std::make_shared<ButtonComponent>(mWindow, "REFINE SEARCH", "refine search", [&] {
|
||||
mSearch->openInputScreen(mSearchParams);
|
||||
mGrid.resetCursor();
|
||||
// Refine the search, unless the result has already been accepted.
|
||||
if (!mSearch->getAcceptedResult()) {
|
||||
mSearch->openInputScreen(mSearchParams);
|
||||
mGrid.resetCursor();
|
||||
}
|
||||
}));
|
||||
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "CANCEL", "cancel", [&] {
|
||||
if (mSearch->getSavedNewMedia()) {
|
||||
|
|
|
@ -79,13 +79,22 @@ GuiScraperMulti::GuiScraperMulti(Window* window,
|
|||
if (mApproveResults) {
|
||||
buttons.push_back(
|
||||
std::make_shared<ButtonComponent>(mWindow, "REFINE SEARCH", "refine search", [&] {
|
||||
mSearchComp->openInputScreen(mSearchQueue.front());
|
||||
mGrid.resetCursor();
|
||||
// Refine the search, unless the result has already been accepted or we're in
|
||||
// semi-automatic mode and there are less than 2 search results.
|
||||
if (!mSearchComp->getAcceptedResult() &&
|
||||
!(mSearchComp->getSearchType() == GuiScraperSearch::ACCEPT_SINGLE_MATCHES &&
|
||||
mSearchComp->getScraperResultSize() < 2)) {
|
||||
mSearchComp->openInputScreen(mSearchQueue.front());
|
||||
mGrid.resetCursor();
|
||||
}
|
||||
}));
|
||||
|
||||
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "SKIP", "skip game", [&] {
|
||||
skip();
|
||||
mGrid.resetCursor();
|
||||
// Skip game, unless the result has already been accepted.
|
||||
if (!mSearchComp->getAcceptedResult()) {
|
||||
skip();
|
||||
mGrid.resetCursor();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ GuiScraperSearch::GuiScraperSearch(Window* window, SearchType type, unsigned int
|
|||
addChild(&mGrid);
|
||||
|
||||
mBlockAccept = false;
|
||||
mAcceptedResult = false;
|
||||
mRetrySearch = false;
|
||||
mRetryCount = 0;
|
||||
|
||||
|
@ -325,6 +326,7 @@ void GuiScraperSearch::updateViewStyle()
|
|||
void GuiScraperSearch::search(const ScraperSearchParams& params)
|
||||
{
|
||||
mBlockAccept = true;
|
||||
mAcceptedResult = false;
|
||||
mMiximageResult = false;
|
||||
mScrapeResult = {};
|
||||
|
||||
|
@ -347,6 +349,7 @@ void GuiScraperSearch::stop()
|
|||
mMDRetrieveURLsHandle.reset();
|
||||
mMiximageGenerator.reset();
|
||||
mBlockAccept = false;
|
||||
mAcceptedResult = false;
|
||||
mMiximageResult = false;
|
||||
mScrapeResult = {};
|
||||
}
|
||||
|
@ -546,12 +549,17 @@ bool GuiScraperSearch::input(InputConfig* config, Input input)
|
|||
return true;
|
||||
}
|
||||
|
||||
// Refine search.
|
||||
if (config->isMappedTo("y", input) && input.value != 0)
|
||||
openInputScreen(mLastSearch);
|
||||
// Refine the search, unless the result has already been accepted or we're in semi-automatic
|
||||
// mode and there are less than 2 search results.
|
||||
if (!mAcceptedResult && config->isMappedTo("y", input) && input.value != 0) {
|
||||
if (mSearchType != ACCEPT_SINGLE_MATCHES ||
|
||||
mSearchType == ACCEPT_SINGLE_MATCHES && mScraperResults.size() > 1) {
|
||||
openInputScreen(mLastSearch);
|
||||
}
|
||||
}
|
||||
|
||||
// Skip game.
|
||||
if (mScrapeCount > 1 && config->isMappedTo("x", input) && input.value != 0)
|
||||
// Skip game, unless the result has already been accepted.
|
||||
if (!mAcceptedResult && mScrapeCount > 1 && config->isMappedTo("x", input) && input.value != 0)
|
||||
mSkipCallback();
|
||||
|
||||
return GuiComponent::input(config, input);
|
||||
|
@ -573,6 +581,7 @@ void GuiScraperSearch::render(const Transform4x4f& parentTrans)
|
|||
void GuiScraperSearch::returnResult(ScraperSearchResult result)
|
||||
{
|
||||
mBlockAccept = true;
|
||||
mAcceptedResult = true;
|
||||
|
||||
// Resolve metadata image before returning.
|
||||
if (result.mediaFilesDownloadStatus != COMPLETED) {
|
||||
|
@ -791,8 +800,8 @@ void GuiScraperSearch::openInputScreen(ScraperSearchParams& params)
|
|||
}
|
||||
else {
|
||||
// If searching based on the actual file name, then expand to the full game name
|
||||
// in case the scraper is set to TheGamesDB and it's an arcade game. This is required
|
||||
// as TheGamesDB has issues with searches using the short MAME names.
|
||||
// in case the scraper is set to TheGamesDB and it's an arcade game. This is
|
||||
// required as TheGamesDB does not support searches using the short MAME names.
|
||||
if (params.game->isArcadeGame() &&
|
||||
Settings::getInstance()->getString("Scraper") == "thegamesdb")
|
||||
searchString = MameNames::getInstance()->getCleanName(params.game->getCleanName());
|
||||
|
|
|
@ -47,6 +47,8 @@ public:
|
|||
void search(const ScraperSearchParams& params);
|
||||
void openInputScreen(ScraperSearchParams& from);
|
||||
void stop();
|
||||
int getScraperResultSize() { return static_cast<int>(mScraperResults.size()); }
|
||||
bool getAcceptedResult() { return mAcceptedResult; }
|
||||
SearchType getSearchType() const { return mSearchType; }
|
||||
bool getSavedNewMedia()
|
||||
{
|
||||
|
@ -145,6 +147,7 @@ private:
|
|||
unsigned int mScrapeCount;
|
||||
bool mRefinedSearch;
|
||||
bool mBlockAccept;
|
||||
bool mAcceptedResult;
|
||||
bool mFoundGame;
|
||||
bool mScrapeRatings;
|
||||
|
||||
|
|
Loading…
Reference in a new issue