Qt: Fix horrific memory leak
Jeffrey Pfau jeffrey@endrift.com
Tue, 06 Sep 2016 12:36:52 -0700
2 files changed,
11 insertions(+),
8 deletions(-)
M
src/platform/qt/Window.cpp
→
src/platform/qt/Window.cpp
@@ -71,7 +71,6 @@ , m_gdbController(nullptr)
#endif , m_mruMenu(nullptr) , m_shortcutController(new ShortcutController(this)) - , m_playerId(playerId) , m_fullscreenOnStart(false) , m_autoresume(false) {@@ -380,14 +379,10 @@ }
} void Window::multiplayerChanged() { - disconnect(nullptr, this, SLOT(multiplayerChanged())); int attached = 1; MultiplayerController* multiplayer = m_controller->multiplayerController(); if (multiplayer) { attached = multiplayer->attached(); - connect(multiplayer, SIGNAL(gameAttached()), this, SLOT(multiplayerChanged())); - connect(multiplayer, SIGNAL(gameDetached()), this, SLOT(multiplayerChanged())); - m_playerId = multiplayer->playerId(m_controller); } if (m_controller->isLoaded()) { for (QAction* action : m_nonMpActions) {@@ -842,7 +837,14 @@ }
} MultiplayerController* multiplayer = m_controller->multiplayerController(); if (multiplayer && multiplayer->attached() > 1) { - title += tr(" - Player %1 of %2").arg(m_playerId + 1).arg(multiplayer->attached()); + title += tr(" - Player %1 of %2").arg(multiplayer->playerId(m_controller) + 1).arg(multiplayer->attached()); + for (QAction* action : m_nonMpActions) { + action->setDisabled(true); + } + } else if (m_controller->isLoaded()) { + for (QAction* action : m_nonMpActions) { + action->setDisabled(false); + } } m_controller->threadContinue(); if (title.isNull()) {@@ -1055,7 +1057,6 @@ QAction* frameAdvance = new QAction(tr("&Next frame"), emulationMenu);
frameAdvance->setShortcut(tr("Ctrl+N")); connect(frameAdvance, SIGNAL(triggered()), m_controller, SLOT(frameAdvance())); m_gameActions.append(frameAdvance); - m_nonMpActions.append(frameAdvance); addControlledAction(emulationMenu, frameAdvance, "frameAdvance"); emulationMenu->addSeparator();@@ -1510,6 +1511,9 @@
void Window::updateMRU() { if (!m_mruMenu) { return; + } + for (QAction* action : m_mruMenu->actions()) { + delete action; } m_mruMenu->clear(); int i = 0;
M
src/platform/qt/Window.h
→
src/platform/qt/Window.h
@@ -173,7 +173,6 @@ QList<QString> m_mruFiles;
QMenu* m_mruMenu; ShortcutController* m_shortcutController; ShaderSelector* m_shaderView; - int m_playerId; bool m_fullscreenOnStart; QTimer m_focusCheck; bool m_autoresume;