From 31cdd7bdd23f74a6d245893b298d95d1a3fc0d42 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sat, 30 Jan 2021 23:45:10 +0100 Subject: [PATCH] Prevent minor race in Progress Dialog Server --- rpcs3/Emu/System.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 1499371d6a..3bbce299e3 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -372,12 +372,17 @@ namespace // Update progress while (thread_ctrl::state() != thread_state::aborting) { - if (ftotal != g_progr_ftotal || fdone != g_progr_fdone || ptotal != g_progr_ptotal || pdone != g_progr_pdone) + const u32 ftotal_new = g_progr_ftotal; + const u32 fdone_new = g_progr_fdone; + const u32 ptotal_new = g_progr_ptotal; + const u32 pdone_new = g_progr_pdone; + + if (ftotal != ftotal_new || fdone != fdone_new || ptotal != ptotal_new || pdone != pdone_new) { - ftotal = g_progr_ftotal; - fdone = g_progr_fdone; - ptotal = g_progr_ptotal; - pdone = g_progr_pdone; + ftotal = ftotal_new; + fdone = fdone_new; + ptotal = ptotal_new; + pdone = pdone_new; // Compute new progress in percents const u32 total = ftotal + ptotal; @@ -418,9 +423,9 @@ namespace } // Cleanup - g_progr_ftotal -= fdone; + g_progr_ftotal -= ftotal; g_progr_fdone -= fdone; - g_progr_ptotal -= pdone; + g_progr_ptotal -= ptotal; g_progr_pdone -= pdone; if (dlg)