all repos — mgba @ c0689783da366b4727c9c15cbc888b8ee3e0ce2a

mGBA Game Boy Advance Emulator

Qt: Fix horrific memory leak
Jeffrey Pfau jeffrey@endrift.com
Tue, 06 Sep 2016 12:36:52 -0700
commit

c0689783da366b4727c9c15cbc888b8ee3e0ce2a

parent

87d4dad893d5df04fac5575c12a1c7b82fc07a7b

2 files changed, 11 insertions(+), 8 deletions(-)

jump to
M src/platform/qt/Window.cppsrc/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.hsrc/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;