all repos — mgba @ f49494cd1d76255d8969057469c69fd82ee0a409

mGBA Game Boy Advance Emulator

Don't open a new state window if one is already open
Jeffrey Pfau jeffrey@endrift.com
Thu, 16 Oct 2014 00:28:41 -0700
commit

f49494cd1d76255d8969057469c69fd82ee0a409

parent

4a9ab53231e03d464c097a652f8f1decd789c57a

2 files changed, 13 insertions(+), 7 deletions(-)

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

@@ -15,12 +15,13 @@ using namespace QGBA;

Window::Window(QWidget* parent) : QMainWindow(parent) + , m_logView(new LogView()) + , m_stateWindow(nullptr) #ifdef USE_GDB_STUB , m_gdbController(nullptr) #endif { m_controller = new GameController(this); - m_logView = new LogView(); QGLFormat format(QGLFormat(QGL::Rgba | QGL::DoubleBuffer)); format.setSwapInterval(1);

@@ -146,16 +147,20 @@ }

} void Window::openStateWindow(LoadSave ls) { + if (m_stateWindow) { + return; + } bool wasPaused = m_controller->isPaused(); - LoadSaveState* window = new LoadSaveState(m_controller); - connect(this, SIGNAL(shutdown()), window, SLOT(hide())); + m_stateWindow = new LoadSaveState(m_controller); + connect(this, SIGNAL(shutdown()), m_stateWindow, SLOT(hide())); + connect(m_stateWindow, &LoadSaveState::closed, [this]() { m_stateWindow = nullptr; }); if (!wasPaused) { m_controller->setPaused(true); - connect(window, &LoadSaveState::closed, [this]() { m_controller->setPaused(false); }); + connect(m_stateWindow, &LoadSaveState::closed, [this]() { m_controller->setPaused(false); }); } - window->setAttribute(Qt::WA_DeleteOnClose); - window->setMode(ls); - window->show(); + m_stateWindow->setAttribute(Qt::WA_DeleteOnClose); + m_stateWindow->setMode(ls); + m_stateWindow->show(); } void Window::setupMenu(QMenuBar* menubar) {
M src/platform/qt/Window.hsrc/platform/qt/Window.h

@@ -58,6 +58,7 @@ GameController* m_controller;

Display* m_display; QList<QAction*> m_gameActions; LogView* m_logView; + LoadSaveState* m_stateWindow; #ifdef USE_GDB_STUB GDBController* m_gdbController;