mirror of https://github.com/PCSX2/pcsx2.git
Qt: Fix crash when spamming shutdown button
This commit is contained in:
parent
36c7f96a1e
commit
5d95a503bf
|
@ -264,7 +264,7 @@ void MainWindow::setupAdditionalUi()
|
|||
connect(action, &QAction::triggered, [scale]() { g_emu_thread->requestDisplaySize(static_cast<float>(scale)); });
|
||||
}
|
||||
|
||||
updateEmulationActions(false, false);
|
||||
updateEmulationActions(false, false, false);
|
||||
updateDisplayRelatedActions(false, false, false);
|
||||
|
||||
#ifdef ENABLE_RAINTEGRATION
|
||||
|
@ -1085,13 +1085,13 @@ void MainWindow::restoreStateFromConfig()
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::updateEmulationActions(bool starting, bool running)
|
||||
void MainWindow::updateEmulationActions(bool starting, bool running, bool stopping)
|
||||
{
|
||||
const bool starting_or_running = starting || running;
|
||||
|
||||
m_ui.actionStartFile->setDisabled(starting_or_running);
|
||||
m_ui.actionStartDisc->setDisabled(starting_or_running);
|
||||
m_ui.actionStartBios->setDisabled(starting_or_running);
|
||||
m_ui.actionStartFile->setDisabled(starting_or_running || stopping);
|
||||
m_ui.actionStartDisc->setDisabled(starting_or_running || stopping);
|
||||
m_ui.actionStartBios->setDisabled(starting_or_running || stopping);
|
||||
|
||||
m_ui.actionPowerOff->setEnabled(running);
|
||||
m_ui.actionPowerOffWithoutSaving->setEnabled(running);
|
||||
|
@ -1116,8 +1116,8 @@ void MainWindow::updateEmulationActions(bool starting, bool running)
|
|||
m_ui.actionPause->setChecked(false);
|
||||
|
||||
// scanning needs to be disabled while running
|
||||
m_ui.actionScanForNewGames->setDisabled(starting_or_running);
|
||||
m_ui.actionRescanAllGames->setDisabled(starting_or_running);
|
||||
m_ui.actionScanForNewGames->setDisabled(starting_or_running || stopping);
|
||||
m_ui.actionRescanAllGames->setDisabled(starting_or_running || stopping);
|
||||
}
|
||||
|
||||
void MainWindow::updateDisplayRelatedActions(bool has_surface, bool render_to_main, bool fullscreen)
|
||||
|
@ -1371,6 +1371,14 @@ bool MainWindow::requestShutdown(bool allow_confirm, bool allow_save_to_state, b
|
|||
if (!isRenderingToMain() && isHidden() && !QtHost::InBatchMode() && !g_emu_thread->isRunningFullscreenUI())
|
||||
updateWindowState(true);
|
||||
|
||||
// Clear the VM valid state early. That way we can't do anything in the UI if we take a while to shut down.
|
||||
if (s_vm_valid)
|
||||
{
|
||||
s_vm_valid = false;
|
||||
updateEmulationActions(false, false, true);
|
||||
updateDisplayRelatedActions(false, false, false);
|
||||
}
|
||||
|
||||
// Now we can actually shut down the VM.
|
||||
g_emu_thread->shutdownVM(save_state);
|
||||
return true;
|
||||
|
@ -1916,7 +1924,7 @@ void MainWindow::onInputRecOpenViewer()
|
|||
void MainWindow::onVMStarting()
|
||||
{
|
||||
s_vm_valid = true;
|
||||
updateEmulationActions(true, false);
|
||||
updateEmulationActions(true, false, false);
|
||||
updateWindowTitle();
|
||||
|
||||
// prevent loading state until we're fully initialized
|
||||
|
@ -1927,7 +1935,7 @@ void MainWindow::onVMStarted()
|
|||
{
|
||||
s_vm_valid = true;
|
||||
m_was_disc_change_request = false;
|
||||
updateEmulationActions(true, true);
|
||||
updateEmulationActions(true, true, false);
|
||||
updateWindowTitle();
|
||||
updateStatusBarWidgetVisibility();
|
||||
updateInputRecordingActions(true);
|
||||
|
@ -1976,7 +1984,7 @@ void MainWindow::onVMStopped()
|
|||
s_vm_valid = false;
|
||||
s_vm_paused = false;
|
||||
m_last_fps_status = QString();
|
||||
updateEmulationActions(false, false);
|
||||
updateEmulationActions(false, false, false);
|
||||
updateWindowTitle();
|
||||
updateWindowState();
|
||||
updateStatusBarWidgetVisibility();
|
||||
|
|
|
@ -213,7 +213,7 @@ private:
|
|||
void saveStateToConfig();
|
||||
void restoreStateFromConfig();
|
||||
|
||||
void updateEmulationActions(bool starting, bool running);
|
||||
void updateEmulationActions(bool starting, bool running, bool stopping);
|
||||
void updateDisplayRelatedActions(bool has_surface, bool render_to_main, bool fullscreen);
|
||||
void updateStatusBarWidgetVisibility();
|
||||
void updateWindowTitle();
|
||||
|
|
Loading…
Reference in New Issue