Qt: Fix Windows not being deleted
Jeffrey Pfau jeffrey@endrift.com
Thu, 18 Jun 2015 19:57:01 -0700
2 files changed,
9 insertions(+),
1 deletions(-)
M
src/platform/qt/GBAApp.cpp
→
src/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.cpp
→
src/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());