From af337124d643661c36f51ac02cc771f45492003d Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Sat, 6 Nov 2021 21:12:13 +0100 Subject: [PATCH] Fixed an issue where an invalid scraper entry in es_settings.xml could lead to a crash. --- es-app/src/guis/GuiScraperMenu.cpp | 5 +++++ es-app/src/scrapers/Scraper.cpp | 11 +++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/es-app/src/guis/GuiScraperMenu.cpp b/es-app/src/guis/GuiScraperMenu.cpp index 17a2526f7..45f6e1683 100644 --- a/es-app/src/guis/GuiScraperMenu.cpp +++ b/es-app/src/guis/GuiScraperMenu.cpp @@ -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 diff --git a/es-app/src/scrapers/Scraper.cpp b/es-app/src/scrapers/Scraper.cpp index e1fbbab6e..3193e4dca 100644 --- a/es-app/src/scrapers/Scraper.cpp +++ b/es-app/src/scrapers/Scraper.cpp @@ -80,8 +80,15 @@ std::vector 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()