Skip to content

Commit

Permalink
Qt: Fix main window stuck open after update
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Mar 22, 2024
1 parent d96062b commit 4d5c8cb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/duckstation-qt/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,8 +588,7 @@ void MainWindow::onSystemDestroyed()
// If we're closing or in batch mode, quit the whole application now.
if (m_is_closing || QtHost::InBatchMode())
{
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents, 1);
QCoreApplication::quit();
quit();
return;
}

Expand Down Expand Up @@ -701,6 +700,22 @@ std::string MainWindow::getDeviceDiscPath(const QString& title)
return ret;
}

void MainWindow::quit()
{
// Make sure VM is gone. It really should be if we're here.
if (s_system_valid)
{
g_emu_thread->shutdownSystem(false);
while (s_system_valid)
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents, 1);
}

// Ensure subwindows are removed before quitting. That way the log window cancelling
// the close event won't cancel the quit process.
destroySubWindows();
QGuiApplication::quit();
}

void MainWindow::recreate()
{
const bool was_display_created = m_display_created;
Expand Down Expand Up @@ -2786,7 +2801,7 @@ void MainWindow::requestExit(bool allow_confirm /* = true */)
if (s_system_valid)
m_is_closing = true;
else
QGuiApplication::quit();
quit();
}

void MainWindow::checkForSettingChanges()
Expand Down
3 changes: 3 additions & 0 deletions src/duckstation-qt/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ class MainWindow final : public QMainWindow
/// Locks the system by pausing it, while a popup dialog is displayed.
SystemLock pauseAndLockSystem();

/// Force quits the application.
void quit();

/// Accessors for the status bar widgets, updated by the emulation thread.
ALWAYS_INLINE QLabel* getStatusRendererWidget() const { return m_status_renderer_widget; }
ALWAYS_INLINE QLabel* getStatusResolutionWidget() const { return m_status_resolution_widget; }
Expand Down

0 comments on commit 4d5c8cb

Please sign in to comment.