Skip to content

Commit

Permalink
GUI: Fix recording related hang when PAD plugin is open/closed while …
Browse files Browse the repository at this point in the history
…game is paused (#3299)

* recording: Resolve hang when opening PAD plugin with the game paused

* pcsx2-gui: Forbid editing the PAD settings while emulation is paused by recording tools

* pcsx2-gui: Resume emulation before configuring PAD plugin, resume on return
  • Loading branch information
xTVaser committed Sep 10, 2020
1 parent fe872b5 commit 79cd8d2
Showing 1 changed file with 36 additions and 7 deletions.
43 changes: 36 additions & 7 deletions pcsx2/gui/MainMenuClicks.cpp
Expand Up @@ -32,9 +32,11 @@

#ifndef DISABLE_RECORDING
# include "Recording/InputRecording.h"
# include "Recording/RecordingControls.h"
# include "Recording/VirtualPad.h"
#endif


using namespace Dialogs;

void MainEmuFrame::Menu_SysSettings_Click(wxCommandEvent &event)
Expand Down Expand Up @@ -471,7 +473,7 @@ void MainEmuFrame::Menu_EnableBackupStates_Click( wxCommandEvent& )
// (1st save after the toggle keeps the old pre-toggle value)..
// wonder what that means for all the other menu checkboxes which only use AppSaveSettings... (avih)
AppApplySettings();
AppSaveSettings();
}

Expand Down Expand Up @@ -553,7 +555,7 @@ void MainEmuFrame::Menu_EnableRecordingTools_Click(wxCommandEvent&)
void MainEmuFrame::Menu_EnableHostFs_Click( wxCommandEvent& )
{
g_Conf->EmuOptions.HostFs = GetMenuBar()->IsChecked( MenuId_EnableHostFs );
AppSaveSettings();
AppSaveSettings();
}

void MainEmuFrame::Menu_OpenELF_Click(wxCommandEvent&)
Expand Down Expand Up @@ -655,20 +657,47 @@ void MainEmuFrame::Menu_SysShutdown_Click(wxCommandEvent &event)
CoreThread.Reset();
}

void MainEmuFrame::Menu_ConfigPlugin_Click(wxCommandEvent &event)
void MainEmuFrame::Menu_ConfigPlugin_Click(wxCommandEvent& event)
{
const int eventId = event.GetId() - MenuId_PluginBase_Settings;

PluginsEnum_t pid = (PluginsEnum_t)(eventId / PluginMenuId_Interval);

// Don't try to call the Patches config dialog until we write one.
if (event.GetId() == MenuId_Config_Patches) return;
if (event.GetId() == MenuId_Config_Patches)
return;

if( !pxAssertDev( (eventId >= 0) || (pid < PluginId_Count), "Invalid plugin identifier passed to ConfigPlugin event handler." ) ) return;
if (!pxAssertDev((eventId >= 0) || (pid < PluginId_Count), "Invalid plugin identifier passed to ConfigPlugin event handler."))
return;

wxWindowDisabler disabler;
ScopedCoreThreadPause paused_core( new SysExecEvent_SaveSinglePlugin(pid) );
GetCorePlugins().Configure( pid );
ScopedCoreThreadPause paused_core(new SysExecEvent_SaveSinglePlugin(pid));

#ifndef DISABLE_RECORDING
if (pid == PluginId_PAD)
{
// The recording features involve pausing emulation, and can be resumed ideally via key-bindings.
//
// However, since the PAD plugin is used to do so, if it's closed then there is nothing to read
// the keybind resulting producing an unrecovable state.
//
// If the CoreThread is paused prior to opening the PAD plugin settings then when the settings
// are closed the PAD will not re-open. To avoid this, we resume emulation prior to the plugins
// configuration handler doing so.
if (g_Conf->EmuOptions.EnableRecordingTools && g_RecordingControls.IsEmulationAndRecordingPaused())
{
g_RecordingControls.Unpause();
GetCorePlugins().Configure(pid);
g_RecordingControls.Pause();
}
else
GetCorePlugins().Configure(pid);
}
else
GetCorePlugins().Configure(pid);
#else
GetCorePlugins().Configure(pid);
#endif
}

void MainEmuFrame::Menu_Debug_Open_Click(wxCommandEvent &event)
Expand Down

0 comments on commit 79cd8d2

Please sign in to comment.