all repos — mgba @ 5e26f74f175289f9968507e460fb6e3e0b16f10c

mGBA Game Boy Advance Emulator

Qt: Fix Windows not being deleted
Jeffrey Pfau jeffrey@endrift.com
Thu, 18 Jun 2015 19:57:01 -0700
commit

5e26f74f175289f9968507e460fb6e3e0b16f10c

parent

5c3074ace99d8f83bf1ecae7ca6033f20a0479a4

2 files changed, 9 insertions(+), 1 deletions(-)

jump to
M src/platform/qt/GBAApp.cppsrc/platform/qt/GBAApp.cpp

@@ -42,6 +42,9 @@ QApplication::setApplicationName(projectName);

QApplication::setApplicationVersion(projectVersion); Window* w = new Window(&m_configController); + connect(w, &Window::destroyed, [this]() { + m_windows[0] = nullptr; + }); m_windows[0] = w; #ifndef Q_OS_MAC

@@ -79,7 +82,11 @@ if (m_multiplayer.attached() >= MAX_GBAS) {

return nullptr; } Window* w = new Window(&m_configController, m_multiplayer.attached()); - m_windows[m_multiplayer.attached()] = w; + int windowId = m_multiplayer.attached(); + connect(w, &Window::destroyed, [this, windowId]() { + m_windows[windowId] = nullptr; + }); + m_windows[windowId] = w; w->setAttribute(Qt::WA_DeleteOnClose); #ifndef Q_OS_MAC w->show();
M src/platform/qt/Window.cppsrc/platform/qt/Window.cpp

@@ -68,6 +68,7 @@ , m_playerId(playerId)

{ setFocusPolicy(Qt::StrongFocus); setAcceptDrops(true); + setAttribute(Qt::WA_DeleteOnClose); m_controller = new GameController(this); m_controller->setInputController(&m_inputController); m_controller->setOverrides(m_config->overrides());