diff --git a/src/platform/qt/GBAApp.cpp b/src/platform/qt/GBAApp.cpp index ee35f1808..7e6da3bdf 100644 --- a/src/platform/qt/GBAApp.cpp +++ b/src/platform/qt/GBAApp.cpp @@ -124,28 +124,27 @@ GBAApp* GBAApp::app() { return g_app; } -void GBAApp::interruptAll() { +void GBAApp::pauseAll(QList* paused) { for (int i = 0; i < MAX_GBAS; ++i) { - if (!m_windows[i] || !m_windows[i]->controller()->isLoaded()) { + if (!m_windows[i] || !m_windows[i]->controller()->isLoaded() || m_windows[i]->controller()->isPaused()) { continue; } - m_windows[i]->controller()->threadInterrupt(); + m_windows[i]->controller()->setPaused(true); + paused->append(i); } } -void GBAApp::continueAll() { - for (int i = 0; i < MAX_GBAS; ++i) { - if (!m_windows[i] || !m_windows[i]->controller()->isLoaded()) { - continue; - } - m_windows[i]->controller()->threadContinue(); +void GBAApp::continueAll(const QList* paused) { + for (int i : *paused) { + m_windows[i]->controller()->setPaused(false); } } QString GBAApp::getOpenFileName(QWidget* owner, const QString& title, const QString& filter) { - interruptAll(); + QList paused; + pauseAll(&paused); QString filename = QFileDialog::getOpenFileName(owner, title, m_configController.getQtOption("lastDirectory").toString(), filter); - continueAll(); + continueAll(&paused); if (!filename.isEmpty()) { m_configController.setQtOption("lastDirectory", QFileInfo(filename).dir().path()); } @@ -153,9 +152,10 @@ QString GBAApp::getOpenFileName(QWidget* owner, const QString& title, const QStr } QString GBAApp::getSaveFileName(QWidget* owner, const QString& title, const QString& filter) { - interruptAll(); + QList paused; + pauseAll(&paused); QString filename = QFileDialog::getSaveFileName(owner, title, m_configController.getQtOption("lastDirectory").toString(), filter); - continueAll(); + continueAll(&paused); if (!filename.isEmpty()) { m_configController.setQtOption("lastDirectory", QFileInfo(filename).dir().path()); } @@ -163,9 +163,10 @@ QString GBAApp::getSaveFileName(QWidget* owner, const QString& title, const QStr } QString GBAApp::getOpenDirectoryName(QWidget* owner, const QString& title) { - interruptAll(); + QList paused; + pauseAll(&paused); QString filename = QFileDialog::getExistingDirectory(owner, title, m_configController.getQtOption("lastDirectory").toString()); - continueAll(); + continueAll(&paused); if (!filename.isEmpty()) { m_configController.setQtOption("lastDirectory", QFileInfo(filename).dir().path()); } @@ -220,12 +221,13 @@ GBAApp::FileDialog::FileDialog(GBAApp* app, QWidget* parent, const QString& capt } int GBAApp::FileDialog::exec() { - m_app->interruptAll(); + QList paused; + m_app->pauseAll(&paused); bool didAccept = QFileDialog::exec() == QDialog::Accepted; QStringList filenames = selectedFiles(); if (!filenames.isEmpty()) { m_app->m_configController.setQtOption("lastDirectory", QFileInfo(filenames[0]).dir().path()); } - m_app->continueAll(); + m_app->continueAll(&paused); return didAccept; } diff --git a/src/platform/qt/GBAApp.h b/src/platform/qt/GBAApp.h index c110a51c3..f30be51f4 100644 --- a/src/platform/qt/GBAApp.h +++ b/src/platform/qt/GBAApp.h @@ -44,10 +44,6 @@ public: const NoIntroDB* gameDB() const { return m_db; } bool reloadGameDB(); -public slots: - void interruptAll(); - void continueAll(); - protected: bool event(QEvent*); @@ -64,6 +60,9 @@ private: Window* newWindowInternal(); + void pauseAll(QList* paused); + void continueAll(const QList* paused); + ConfigController m_configController; Window* m_windows[MAX_GBAS]; MultiplayerController m_multiplayer;