Fixed a small memory leak in GuiScraperMenu related to the retry sliders

This commit is contained in:
Leon Styhre 2023-07-11 14:56:20 +02:00
parent a4911246a2
commit f89c31d29e
2 changed files with 14 additions and 12 deletions

View file

@ -14,7 +14,6 @@
#include "FileSorts.h" #include "FileSorts.h"
#include "SystemData.h" #include "SystemData.h"
#include "components/OptionListComponent.h" #include "components/OptionListComponent.h"
#include "components/SliderComponent.h"
#include "components/SwitchComponent.h" #include "components/SwitchComponent.h"
#include "guis/GuiMsgBox.h" #include "guis/GuiMsgBox.h"
#include "guis/GuiOfflineGenerator.h" #include "guis/GuiOfflineGenerator.h"
@ -867,15 +866,16 @@ void GuiScraperMenu::openOtherOptions()
} }
// Automatic retries on error. // Automatic retries on error.
auto scraperRetryOnErrorCount = std::make_shared<SliderComponent>(0.0f, 10.0f, 1.0f); mScraperRetryOnErrorCount = std::make_shared<SliderComponent>(0.0f, 10.0f, 1.0f);
scraperRetryOnErrorCount->setValue( mScraperRetryOnErrorCount->setValue(
static_cast<float>(Settings::getInstance()->getInt("ScraperRetryOnErrorCount"))); static_cast<float>(Settings::getInstance()->getInt("ScraperRetryOnErrorCount")));
s->addWithLabel("AUTOMATIC RETRIES ON ERROR", scraperRetryOnErrorCount); s->addWithLabel("AUTOMATIC RETRIES ON ERROR", mScraperRetryOnErrorCount);
s->addSaveFunc([scraperRetryOnErrorCount, s] { s->addSaveFunc([this, s] {
if (scraperRetryOnErrorCount->getValue() != if (mScraperRetryOnErrorCount->getValue() !=
static_cast<float>(Settings::getInstance()->getInt("ScraperRetryOnErrorCount"))) { static_cast<float>(Settings::getInstance()->getInt("ScraperRetryOnErrorCount"))) {
Settings::getInstance()->setInt("ScraperRetryOnErrorCount", Settings::getInstance()->setInt(
static_cast<int>(scraperRetryOnErrorCount->getValue())); "ScraperRetryOnErrorCount",
static_cast<int>(mScraperRetryOnErrorCount->getValue()));
s->setNeedsSaving(); s->setNeedsSaving();
} }
}); });
@ -894,7 +894,7 @@ void GuiScraperMenu::openOtherOptions()
} }
}); });
if (scraperRetryOnErrorCount->getValue() == 0.0f) { if (mScraperRetryOnErrorCount->getValue() == 0.0f) {
scraperRetryOnErrorTimer->setEnabled(false); scraperRetryOnErrorTimer->setEnabled(false);
scraperRetryOnErrorTimer->setOpacity(DISABLED_OPACITY); scraperRetryOnErrorTimer->setOpacity(DISABLED_OPACITY);
scraperRetryOnErrorTimer->getParent() scraperRetryOnErrorTimer->getParent()
@ -1087,8 +1087,8 @@ void GuiScraperMenu::openOtherOptions()
} }
// Slider callback. // Slider callback.
auto scraperRetryCountFunc = [scraperRetryOnErrorCount, scraperRetryOnErrorTimer]() { auto scraperRetryCountFunc = [this, scraperRetryOnErrorTimer]() {
if (scraperRetryOnErrorCount->getValue() == 0.0f) { if (mScraperRetryOnErrorCount->getValue() == 0.0f) {
scraperRetryOnErrorTimer->setEnabled(false); scraperRetryOnErrorTimer->setEnabled(false);
scraperRetryOnErrorTimer->setOpacity(DISABLED_OPACITY); scraperRetryOnErrorTimer->setOpacity(DISABLED_OPACITY);
scraperRetryOnErrorTimer->getParent() scraperRetryOnErrorTimer->getParent()
@ -1139,7 +1139,7 @@ void GuiScraperMenu::openOtherOptions()
} }
}; };
scraperRetryOnErrorCount->setCallback(scraperRetryCountFunc); mScraperRetryOnErrorCount->setCallback(scraperRetryCountFunc);
scraperInteractive->setCallback(interactiveToggleFunc); scraperInteractive->setCallback(interactiveToggleFunc);
scraperRespectExclusions->setCallback(excludeRecursivelyToggleFunc); scraperRespectExclusions->setCallback(excludeRecursivelyToggleFunc);

View file

@ -12,6 +12,7 @@
#define ES_APP_GUIS_GUI_SCRAPER_MENU_H #define ES_APP_GUIS_GUI_SCRAPER_MENU_H
#include "components/MenuComponent.h" #include "components/MenuComponent.h"
#include "components/SliderComponent.h"
#include "guis/GuiSettings.h" #include "guis/GuiSettings.h"
#include "scrapers/Scraper.h" #include "scrapers/Scraper.h"
#include "views/ViewController.h" #include "views/ViewController.h"
@ -54,6 +55,7 @@ private:
std::shared_ptr<OptionListComponent<std::string>> mScraper; std::shared_ptr<OptionListComponent<std::string>> mScraper;
std::shared_ptr<OptionListComponent<GameFilterFunc>> mFilters; std::shared_ptr<OptionListComponent<GameFilterFunc>> mFilters;
std::shared_ptr<OptionListComponent<SystemData*>> mSystems; std::shared_ptr<OptionListComponent<SystemData*>> mSystems;
std::shared_ptr<SliderComponent> mScraperRetryOnErrorCount;
MenuComponent mMenu; MenuComponent mMenu;
}; };