From e3c8f69953251a030c77476748ba4759e8c561ac Mon Sep 17 00:00:00 2001 From: Eladash Date: Sun, 31 Jan 2021 07:11:36 +0200 Subject: [PATCH 1/3] Fix potential crash of progress dialog --- rpcs3/Emu/System.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 3bbce299e3ab..6cff0c6da02d 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -78,7 +78,7 @@ std::array, 16> g_tty_input; std::mutex g_tty_mutex; // Progress display server synchronization variables -atomic_t g_progr{nullptr}; +atomic_t g_progr{""}; atomic_t g_progr_ftotal{0}; atomic_t g_progr_fdone{0}; atomic_t g_progr_ptotal{0}; From 382f8819c93dafc4bf66b15fa044157a0350414b Mon Sep 17 00:00:00 2001 From: Eladash Date: Sun, 31 Jan 2021 07:30:42 +0200 Subject: [PATCH 2/3] Fix ppu progress dialog percentage --- rpcs3/Emu/System.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 6cff0c6da02d..e542cd688858 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -385,9 +385,10 @@ namespace pdone = pdone_new; // Compute new progress in percents - const u32 total = ftotal + ptotal; - const u32 done = fdone + pdone; - const double value = double(done) * 100. / double(total ? total : 1); + // Assume not all programs were found if files were not compiled (as it may contain more) + const u64 total = std::max(ptotal, 1) * std::max(ftotal, 1); + const u64 done = pdone * std::max(fdone, 1); + const double value = std::fmin(done * 100. / total, 100.); // Changes detected, send update Emu.CallAfter([=]() From 1cd045d818e29ab227efb7843aa7dac0dc356d5c Mon Sep 17 00:00:00 2001 From: Eladash Date: Sun, 31 Jan 2021 08:29:07 +0200 Subject: [PATCH 3/3] Add missing destructor of progress dialog --- rpcs3/Emu/System.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index e542cd688858..38d882c8f3b2 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -439,6 +439,14 @@ namespace } } + ~progress_dialog_server() + { + g_progr_ftotal.release(0); + g_progr_fdone.release(0); + g_progr_ptotal.release(0); + g_progr_pdone.release(0); + } + static auto constexpr thread_name = "Progress Dialog Server"sv; }; }