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