mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 06:05:38 +00:00
Fixed some memory leaks
This commit is contained in:
parent
82d6693e23
commit
24801680c5
|
@ -44,6 +44,7 @@
|
|||
GuiMenu::GuiMenu()
|
||||
: mRenderer {Renderer::getInstance()}
|
||||
, mMenu {"MAIN MENU"}
|
||||
, mThemeDownloaderReloadCounter {0}
|
||||
{
|
||||
const bool isFullUI {UIModeController::getInstance()->isUIModeFull()};
|
||||
|
||||
|
@ -477,10 +478,14 @@ void GuiMenu::openUIOptions()
|
|||
if (systemsSorting->getSelectedObjects().size() == 0)
|
||||
systemsSorting->selectEntry(0);
|
||||
s->addWithLabel("SYSTEMS SORTING", systemsSorting);
|
||||
s->addSaveFunc([systemsSorting, s] {
|
||||
s->addSaveFunc([this, systemsSorting, s] {
|
||||
if (systemsSorting->getSelected() != Settings::getInstance()->getString("SystemsSorting")) {
|
||||
Settings::getInstance()->setString("SystemsSorting", systemsSorting->getSelected());
|
||||
s->setNeedsSaving();
|
||||
if (mThemeDownloaderReloadCounter == 0)
|
||||
s->setNeedsCloseMenu([this] { delete this; });
|
||||
else
|
||||
++mThemeDownloaderReloadCounter;
|
||||
s->setNeedsRescanROMDirectory();
|
||||
}
|
||||
});
|
||||
|
@ -535,13 +540,16 @@ void GuiMenu::openUIOptions()
|
|||
if (menuColorScheme->getSelectedObjects().size() == 0)
|
||||
menuColorScheme->selectEntry(0);
|
||||
s->addWithLabel("MENU COLOR SCHEME", menuColorScheme);
|
||||
s->addSaveFunc([menuColorScheme, s] {
|
||||
s->addSaveFunc([this, menuColorScheme, s] {
|
||||
if (menuColorScheme->getSelected() !=
|
||||
Settings::getInstance()->getString("MenuColorScheme")) {
|
||||
Settings::getInstance()->setString("MenuColorScheme", menuColorScheme->getSelected());
|
||||
ViewController::getInstance()->setMenuColors();
|
||||
s->setNeedsSaving();
|
||||
s->setNeedsCloseAllWindows();
|
||||
if (mThemeDownloaderReloadCounter == 0)
|
||||
s->setNeedsCloseMenu([this] { delete this; });
|
||||
else
|
||||
++mThemeDownloaderReloadCounter;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1567,7 +1575,7 @@ void GuiMenu::openOtherOptions()
|
|||
if (showQuitMenu->getState() != Settings::getInstance()->getBool("ShowQuitMenu")) {
|
||||
Settings::getInstance()->setBool("ShowQuitMenu", showQuitMenu->getState());
|
||||
s->setNeedsSaving();
|
||||
s->setNeedsCloseAllWindows();
|
||||
s->setNeedsCloseMenu([this] { delete this; });
|
||||
}
|
||||
});
|
||||
#endif
|
||||
|
@ -1746,9 +1754,15 @@ void GuiMenu::openThemeDownloader(GuiSettings* settings)
|
|||
{
|
||||
auto updateFunc = [&, settings]() {
|
||||
LOG(LogDebug) << "GuiMenu::openThemeDownloader(): Theme sets were updated, reloading menu";
|
||||
mThemeDownloaderReloadCounter = 1;
|
||||
delete settings;
|
||||
openUIOptions();
|
||||
mWindow->invalidateCachedBackground();
|
||||
if (mThemeDownloaderReloadCounter != 1) {
|
||||
delete this;
|
||||
}
|
||||
else {
|
||||
openUIOptions();
|
||||
mWindow->invalidateCachedBackground();
|
||||
}
|
||||
};
|
||||
|
||||
mWindow->pushGui(new GuiThemeDownloader(updateFunc));
|
||||
|
|
|
@ -50,6 +50,7 @@ private:
|
|||
Renderer* mRenderer;
|
||||
MenuComponent mMenu;
|
||||
TextComponent mVersion;
|
||||
int mThemeDownloaderReloadCounter;
|
||||
};
|
||||
|
||||
#endif // ES_APP_GUIS_GUI_MENU_H
|
||||
|
|
|
@ -36,7 +36,6 @@ GuiSettings::GuiSettings(std::string title)
|
|||
, mNeedsGoToStart {false}
|
||||
, mNeedsGoToSystem {false}
|
||||
, mNeedsGoToGroupedCollections {false}
|
||||
, mNeedsCloseAllWindows {false}
|
||||
, mInvalidateCachedBackground {false}
|
||||
{
|
||||
addChild(&mMenu);
|
||||
|
@ -72,13 +71,10 @@ void GuiSettings::save()
|
|||
for (auto system : SystemData::sSystemVector)
|
||||
system->writeMetaData();
|
||||
}
|
||||
// If a close menu function was passed to us, then run it.
|
||||
if (mCloseMenuFunction)
|
||||
mCloseMenuFunction();
|
||||
ViewController::getInstance()->rescanROMDirectory();
|
||||
// Close all open windows.
|
||||
while (mWindow->getGuiStackSize() > 1) {
|
||||
GuiComponent* window {mWindow->peekGui()};
|
||||
if (window != nullptr)
|
||||
mWindow->removeGui(window);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -176,13 +172,9 @@ void GuiSettings::save()
|
|||
ViewController::getInstance()->resetCamera();
|
||||
}
|
||||
|
||||
if (mNeedsCloseAllWindows) {
|
||||
while (mWindow->getGuiStackSize() > 1) {
|
||||
GuiComponent* window {mWindow->peekGui()};
|
||||
if (window != nullptr)
|
||||
mWindow->removeGui(window);
|
||||
}
|
||||
}
|
||||
// If a close menu function was passed to us, then run it.
|
||||
if (mCloseMenuFunction)
|
||||
mCloseMenuFunction();
|
||||
|
||||
if (mInvalidateCachedBackground) {
|
||||
// This delay reduces the likelyhood that the SVG rasterizer which is running in a
|
||||
|
|
|
@ -58,7 +58,10 @@ public:
|
|||
mGoToSystem = goToSystem;
|
||||
};
|
||||
void setNeedsGoToGroupedCollections() { mNeedsGoToGroupedCollections = true; }
|
||||
void setNeedsCloseAllWindows() { mNeedsCloseAllWindows = true; }
|
||||
void setNeedsCloseMenu(std::function<void()> closeFunction)
|
||||
{
|
||||
mCloseMenuFunction = closeFunction;
|
||||
}
|
||||
void setInvalidateCachedBackground() { mInvalidateCachedBackground = true; }
|
||||
|
||||
bool input(InputConfig* config, Input input) override;
|
||||
|
@ -69,6 +72,7 @@ private:
|
|||
Renderer* mRenderer;
|
||||
MenuComponent mMenu;
|
||||
std::vector<std::function<void()>> mSaveFuncs;
|
||||
std::function<void()> mCloseMenuFunction;
|
||||
SystemData* mGoToSystem;
|
||||
|
||||
bool mNeedsSaving;
|
||||
|
@ -81,7 +85,6 @@ private:
|
|||
bool mNeedsGoToStart;
|
||||
bool mNeedsGoToSystem;
|
||||
bool mNeedsGoToGroupedCollections;
|
||||
bool mNeedsCloseAllWindows;
|
||||
bool mInvalidateCachedBackground;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue