Fixed an issue where an invalid scraper entry in es_settings.xml could lead to a crash.

This commit is contained in:
Leon Styhre 2021-11-06 21:12:13 +01:00
parent 46228c6a9d
commit af337124d6
2 changed files with 14 additions and 2 deletions

View file

@ -32,6 +32,11 @@ GuiScraperMenu::GuiScraperMenu(Window* window, std::string title)
// just in case the scraper from settings has vanished.
for (auto it = scrapers.cbegin(); it != scrapers.cend(); it++)
mScraper->add(*it, *it, *it == Settings::getInstance()->getString("Scraper"));
// If there are no objects returned, then there must be a manually modified entry in the
// configuration file. Simply set the scraper to "screenscraper" in this case.
if (mScraper->getSelectedObjects().size() == 0)
mScraper->selectEntry(0);
mMenu.addWithLabel("SCRAPE FROM", mScraper);
// Search filters, getSearches() will generate a queue of games to scrape

View file

@ -80,8 +80,15 @@ std::vector<std::string> getScraperList()
bool isValidConfiguredScraper()
{
const std::string& name = Settings::getInstance()->getString("Scraper");
return scraper_request_funcs.find(name) != scraper_request_funcs.end();
std::string scraper = Settings::getInstance()->getString("Scraper");
// Handle a potentially invalid entry in the configuration file.
if (scraper != "screenscraper" && scraper != "thegamesdb") {
scraper = "screenscraper";
Settings::getInstance()->setString("Scraper", scraper);
Settings::getInstance()->saveFile();
}
return scraper_request_funcs.find(scraper) != scraper_request_funcs.end();
}
void ScraperSearchHandle::update()