mirror of https://github.com/PCSX2/pcsx2.git
input-rec: Resolve crash when closing emulator involving GUI elements
Gist is we paused the CoreThread without resuming it (input recording would wait until the next VSync), the shutdown routine triggers it when all required window elements are already cleaned up, hence the crash. Reproduction Steps: - boot game so gs window is open - open the dialog for a new input recording, then close it - close the GS window - re-open the dialog for a new input recording, then close it - close pcsx2, should error.
This commit is contained in:
parent
467659200d
commit
82ce20210f
|
@ -1,5 +1,5 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2020 PCSX2 Dev Team
|
||||
* Copyright (C) 2002-2021 PCSX2 Dev Team
|
||||
*
|
||||
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU Lesser General Public License as published by the Free Software Found-
|
||||
|
@ -142,6 +142,18 @@ void InputRecordingControls::Resume()
|
|||
resumeEmulation = true;
|
||||
}
|
||||
|
||||
void InputRecordingControls::ResumeImmediately()
|
||||
{
|
||||
if (!CoreThread.IsPaused())
|
||||
return;
|
||||
Resume();
|
||||
if (CoreThread.IsPaused() && CoreThread.IsRunning())
|
||||
{
|
||||
emulationCurrentlyPaused = false;
|
||||
CoreThread.Resume();
|
||||
}
|
||||
}
|
||||
|
||||
void InputRecordingControls::TogglePause()
|
||||
{
|
||||
if (pauseEmulation &&
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2020 PCSX2 Dev Team
|
||||
* Copyright (C) 2002-2021 PCSX2 Dev Team
|
||||
*
|
||||
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU Lesser General Public License as published by the Free Software Found-
|
||||
|
@ -38,19 +38,19 @@ public:
|
|||
// Called much more frequently than HandleFrameAdvanceAndPausing, instead of being per frame
|
||||
// this hooks into pcsx2's main App event handler as it has to be able to resume emulation
|
||||
// when drawing frames has compltely stopped
|
||||
//
|
||||
//
|
||||
// Resumes emulation if:
|
||||
// - CoreThread is currently open and paused
|
||||
// - We've signaled emulation to be resumed via TogglePause or FrameAdvancing
|
||||
void ResumeCoreThreadIfStarted();
|
||||
|
||||
|
||||
// Resume emulation (incase the emulation is currently paused) and pause after a single frame has passed
|
||||
void FrameAdvance();
|
||||
// Returns true if emulation is currently set up to frame advance.
|
||||
bool IsFrameAdvancing();
|
||||
// Returns true if the input recording has been paused, which can occur:
|
||||
// - After a single frame has passed after InputRecordingControls::FrameAdvance
|
||||
// - Explicitly paused via an InputRecordingControls function
|
||||
// - Explicitly paused via an InputRecordingControls function
|
||||
bool IsPaused();
|
||||
// Pause emulation at the next available Vsync
|
||||
void Pause();
|
||||
|
@ -58,6 +58,10 @@ public:
|
|||
void PauseImmediately();
|
||||
// Resume emulation when the next pcsx2 App event is handled
|
||||
void Resume();
|
||||
/**
|
||||
* @brief Resumes emulation immediately, don't wait until the next VSync
|
||||
*/
|
||||
void ResumeImmediately();
|
||||
// Alternates emulation between a paused and unpaused state
|
||||
void TogglePause();
|
||||
// Switches between recording and replaying the active input recording file
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2010 PCSX2 Dev Team
|
||||
* Copyright (C) 2002-2021 PCSX2 Dev Team
|
||||
*
|
||||
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU Lesser General Public License as published by the Free Software Found-
|
||||
|
@ -1045,9 +1045,10 @@ void MainEmuFrame::Menu_Capture_Screenshot_Screenshot_As_Click(wxCommandEvent& e
|
|||
#ifndef DISABLE_RECORDING
|
||||
void MainEmuFrame::Menu_Recording_New_Click(wxCommandEvent& event)
|
||||
{
|
||||
const bool initiallyPaused = g_InputRecordingControls.IsPaused();
|
||||
const bool emulation_initially_paused = CoreThread.IsPaused();
|
||||
const bool recording_initially_paused = g_InputRecordingControls.IsPaused();
|
||||
|
||||
if (!initiallyPaused)
|
||||
if (!emulation_initially_paused && !recording_initially_paused)
|
||||
g_InputRecordingControls.PauseImmediately();
|
||||
|
||||
NewRecordingFrame* newRecordingFrame = wxGetApp().GetNewRecordingFramePtr();
|
||||
|
@ -1063,8 +1064,8 @@ void MainEmuFrame::Menu_Recording_New_Click(wxCommandEvent& event)
|
|||
}
|
||||
}
|
||||
|
||||
if (!initiallyPaused)
|
||||
g_InputRecordingControls.Resume();
|
||||
if (!emulation_initially_paused && !recording_initially_paused)
|
||||
g_InputRecordingControls.ResumeImmediately();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue