mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 22:00:39 -06:00
VideoConfig: Prevent race condition on g_Config when refreshing
There was a race condition between the video thread and the host thread, 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.
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user