From b0a24665e5e2d7483582d611c1727a1da5970d4f Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sun, 6 Jan 2019 23:00:48 +0100 Subject: [PATCH] Emu: msg_dialog_frame fixes --- rpcs3/Emu/Cell/Modules/cellMsgDialog.h | 1 + rpcs3/Emu/System.cpp | 13 +++++++++---- rpcs3/rpcs3qt/msg_dialog_frame.cpp | 14 +++++++++----- rpcs3/rpcs3qt/msg_dialog_frame.h | 1 + 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellMsgDialog.h b/rpcs3/Emu/Cell/Modules/cellMsgDialog.h index 75131192f7..0527f77b48 100644 --- a/rpcs3/Emu/Cell/Modules/cellMsgDialog.h +++ b/rpcs3/Emu/Cell/Modules/cellMsgDialog.h @@ -100,6 +100,7 @@ public: virtual ~MsgDialogBase(); virtual void Create(const std::string& msg, const std::string& title = "") = 0; + virtual void Close() = 0; virtual void SetMsg(const std::string& msg) = 0; virtual void ProgressBarSetMsg(u32 progressBarIndex, const std::string& msg) = 0; virtual void ProgressBarReset(u32 progressBarIndex) = 0; diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 5693c97868..693c8eb493 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -340,8 +340,6 @@ void Emulator::Init() { while (true) { - std::shared_ptr dlg; - // Wait for the start condition while (!g_progr_ftotal && !g_progr_ptotal) { @@ -349,7 +347,7 @@ void Emulator::Init() } // Initialize message dialog - dlg = Emu.GetCallbacks().get_msg_dialog(); + std::shared_ptr dlg = Emu.GetCallbacks().get_msg_dialog(); dlg->type.se_normal = true; dlg->type.bg_invisible = true; dlg->type.progress_bar_count = 1; @@ -384,7 +382,9 @@ void Emulator::Init() pdone = g_progr_pdone; // Compute new progress in percents - const u32 new_value = ((ptotal ? pdone * 1. / ptotal : 0.) + fdone) * 100. / (ftotal ? ftotal : 1); + const u32 total = ftotal + ptotal; + const u32 done = fdone + pdone; + const u32 new_value = double(done) * 100. / double(total ? total : 1); // Compute the difference const u32 delta = new_value > value ? new_value - value : 0; @@ -421,6 +421,11 @@ void Emulator::Init() g_progr_fdone -= fdone; g_progr_ptotal -= pdone; g_progr_pdone -= pdone; + + Emu.CallAfter([=] + { + dlg->Close(); + }); } }); diff --git a/rpcs3/rpcs3qt/msg_dialog_frame.cpp b/rpcs3/rpcs3qt/msg_dialog_frame.cpp index 1a0ba5aa88..f8ce44e23d 100644 --- a/rpcs3/rpcs3qt/msg_dialog_frame.cpp +++ b/rpcs3/rpcs3qt/msg_dialog_frame.cpp @@ -13,11 +13,7 @@ void msg_dialog_frame::Create(const std::string& msg, const std::string& title) static const auto& barWidth = [](){return QLabel("This is the very length of the progressbar due to hidpi reasons.").sizeHint().width();}; - if (m_dialog) - { - m_dialog->close(); - delete m_dialog; - } + Close(); m_dialog = new custom_dialog(type.disable_cancel); m_dialog->setWindowTitle(title.empty() ? (type.se_normal ? "Normal dialog" : "Error dialog") : qstr(title)); @@ -152,6 +148,14 @@ void msg_dialog_frame::Create(const std::string& msg, const std::string& title) #endif } +void msg_dialog_frame::Close() +{ + if (m_dialog) + { + m_dialog->close(); + } +} + msg_dialog_frame::msg_dialog_frame(QWindow* taskbarTarget) : m_taskbarTarget(taskbarTarget) {} msg_dialog_frame::~msg_dialog_frame() diff --git a/rpcs3/rpcs3qt/msg_dialog_frame.h b/rpcs3/rpcs3qt/msg_dialog_frame.h index e607273814..5607fc2107 100644 --- a/rpcs3/rpcs3qt/msg_dialog_frame.h +++ b/rpcs3/rpcs3qt/msg_dialog_frame.h @@ -53,6 +53,7 @@ public: msg_dialog_frame(QWindow* taskbarTarget); ~msg_dialog_frame(); virtual void Create(const std::string& msg, const std::string& title = "") override; + virtual void Close() override; virtual void SetMsg(const std::string& msg) override; virtual void ProgressBarSetMsg(u32 progressBarIndex, const std::string& msg) override; virtual void ProgressBarReset(u32 progressBarIndex) override;