Merge pull request #6112 from stenzek/videoconfig-race
VideoConfig: Prevent race condition on g_Config when refreshing
This commit is contained in:
commit
6230860925
|
@ -321,6 +321,9 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string& title)
|
|||
wxGetTranslation(StrToWxStr(title)))),
|
||||
vconfig(g_Config)
|
||||
{
|
||||
// We don't need to load the config if the core is running, since it would have been done
|
||||
// at startup time already.
|
||||
if (!Core::IsRunning())
|
||||
vconfig.Refresh();
|
||||
|
||||
Bind(wxEVT_UPDATE_UI, &VideoConfigDiag::OnUpdateUI, this);
|
||||
|
|
|
@ -192,7 +192,6 @@ void VideoBackendBase::InitializeShared()
|
|||
|
||||
g_Config.Refresh();
|
||||
g_Config.UpdateProjectionHack();
|
||||
g_Config.VerifyValidity();
|
||||
UpdateActiveConfig();
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,12 @@ void VideoConfig::Refresh()
|
|||
{
|
||||
if (!s_has_registered_callback)
|
||||
{
|
||||
Config::AddConfigChangedCallback([]() { g_Config.Refresh(); });
|
||||
// There was a race condition between the video thread and the host thread here, if
|
||||
// corrections need to be made by VerifyValidity(). Briefly, the config will contain
|
||||
// invalid values. Instead, pause emulation first, which will flush the video thread,
|
||||
// update the config and correct it, then resume emulation, after which the video
|
||||
// thread will detect the config has changed and act accordingly.
|
||||
Config::AddConfigChangedCallback([]() { Core::RunAsCPUThread([]() { g_Config.Refresh(); }); });
|
||||
s_has_registered_callback = true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue