mirror of https://github.com/mgba-emu/mgba.git
Don't open a new state window if one is already open
This commit is contained in:
parent
4a9ab53231
commit
f49494cd1d
|
@ -15,12 +15,13 @@ using namespace QGBA;
|
||||||
|
|
||||||
Window::Window(QWidget* parent)
|
Window::Window(QWidget* parent)
|
||||||
: QMainWindow(parent)
|
: QMainWindow(parent)
|
||||||
|
, m_logView(new LogView())
|
||||||
|
, m_stateWindow(nullptr)
|
||||||
#ifdef USE_GDB_STUB
|
#ifdef USE_GDB_STUB
|
||||||
, m_gdbController(nullptr)
|
, m_gdbController(nullptr)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
m_controller = new GameController(this);
|
m_controller = new GameController(this);
|
||||||
m_logView = new LogView();
|
|
||||||
|
|
||||||
QGLFormat format(QGLFormat(QGL::Rgba | QGL::DoubleBuffer));
|
QGLFormat format(QGLFormat(QGL::Rgba | QGL::DoubleBuffer));
|
||||||
format.setSwapInterval(1);
|
format.setSwapInterval(1);
|
||||||
|
@ -146,16 +147,20 @@ void Window::gameStopped() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::openStateWindow(LoadSave ls) {
|
void Window::openStateWindow(LoadSave ls) {
|
||||||
|
if (m_stateWindow) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
bool wasPaused = m_controller->isPaused();
|
bool wasPaused = m_controller->isPaused();
|
||||||
LoadSaveState* window = new LoadSaveState(m_controller);
|
m_stateWindow = new LoadSaveState(m_controller);
|
||||||
connect(this, SIGNAL(shutdown()), window, SLOT(hide()));
|
connect(this, SIGNAL(shutdown()), m_stateWindow, SLOT(hide()));
|
||||||
|
connect(m_stateWindow, &LoadSaveState::closed, [this]() { m_stateWindow = nullptr; });
|
||||||
if (!wasPaused) {
|
if (!wasPaused) {
|
||||||
m_controller->setPaused(true);
|
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);
|
m_stateWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
window->setMode(ls);
|
m_stateWindow->setMode(ls);
|
||||||
window->show();
|
m_stateWindow->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::setupMenu(QMenuBar* menubar) {
|
void Window::setupMenu(QMenuBar* menubar) {
|
||||||
|
|
|
@ -58,6 +58,7 @@ private:
|
||||||
Display* m_display;
|
Display* m_display;
|
||||||
QList<QAction*> m_gameActions;
|
QList<QAction*> m_gameActions;
|
||||||
LogView* m_logView;
|
LogView* m_logView;
|
||||||
|
LoadSaveState* m_stateWindow;
|
||||||
|
|
||||||
#ifdef USE_GDB_STUB
|
#ifdef USE_GDB_STUB
|
||||||
GDBController* m_gdbController;
|
GDBController* m_gdbController;
|
||||||
|
|
Loading…
Reference in New Issue