Don't open a new state window if one is already open

This commit is contained in:
Jeffrey Pfau 2014-10-16 00:28:41 -07:00
parent 4a9ab53231
commit f49494cd1d
2 changed files with 13 additions and 7 deletions

View File

@ -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::gameStopped() {
}
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) {

View File

@ -58,6 +58,7 @@ private:
Display* m_display;
QList<QAction*> m_gameActions;
LogView* m_logView;
LoadSaveState* m_stateWindow;
#ifdef USE_GDB_STUB
GDBController* m_gdbController;