From a09900a64f312544c6e6e64bf57b0209c447798d Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sat, 9 Mar 2024 17:57:27 +0100 Subject: [PATCH] Qt: make sure to actually delete the progress dialog when it is closed Also add some more cleanup code for the gamelist refresh progress dialog --- rpcs3/rpcs3qt/game_list_frame.cpp | 26 +++++++++++++++++++++++--- rpcs3/rpcs3qt/progress_dialog.cpp | 3 ++- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/rpcs3/rpcs3qt/game_list_frame.cpp b/rpcs3/rpcs3qt/game_list_frame.cpp index b2b44511dc..5fb6de57db 100644 --- a/rpcs3/rpcs3qt/game_list_frame.cpp +++ b/rpcs3/rpcs3qt/game_list_frame.cpp @@ -301,8 +301,8 @@ void game_list_frame::Refresh(const bool from_drive, const bool scroll_after) if (m_progress_dialog) { + m_progress_dialog->SetValue(m_progress_dialog->maximum()); m_progress_dialog->accept(); - m_progress_dialog->deleteLater(); m_progress_dialog = nullptr; } @@ -331,6 +331,27 @@ void game_list_frame::Refresh(const bool from_drive, const bool scroll_after) m_progress_dialog->SetValue(value); } }, Qt::QueuedConnection); + connect(&m_refresh_watcher, &QFutureWatcher::finished, this, [this]() + { + if (m_progress_dialog) + { + m_progress_dialog->SetValue(m_progress_dialog->maximum()); + m_progress_dialog->accept(); + m_progress_dialog = nullptr; + } + }, Qt::QueuedConnection); + connect(&m_refresh_watcher, &QFutureWatcher::canceled, this, [this]() + { + if (m_progress_dialog) + { + m_progress_dialog->accept(); + m_progress_dialog = nullptr; + } + }, Qt::QueuedConnection); + connect(m_progress_dialog, &QProgressDialog::finished, this, [this]() + { + m_progress_dialog = nullptr; + }); connect(m_progress_dialog, &QProgressDialog::canceled, this, [this]() { gui::utils::stop_future_watcher(m_parsing_watcher, true); @@ -348,7 +369,6 @@ void game_list_frame::Refresh(const bool from_drive, const bool scroll_after) m_progress_dialog_timer->stop(); } - m_progress_dialog->deleteLater(); m_progress_dialog = nullptr; }); @@ -826,8 +846,8 @@ void game_list_frame::OnRefreshFinished() if (m_progress_dialog) { + m_progress_dialog->SetValue(m_progress_dialog->maximum()); m_progress_dialog->accept(); - m_progress_dialog->deleteLater(); m_progress_dialog = nullptr; } diff --git a/rpcs3/rpcs3qt/progress_dialog.cpp b/rpcs3/rpcs3qt/progress_dialog.cpp index 6c6ed34591..7fc560e564 100644 --- a/rpcs3/rpcs3qt/progress_dialog.cpp +++ b/rpcs3/rpcs3qt/progress_dialog.cpp @@ -51,7 +51,8 @@ void progress_dialog::SetValue(int progress) void progress_dialog::SetDeleteOnClose() { - connect(this, &QProgressDialog::canceled, this, &QProgressDialog::deleteLater); + setAttribute(Qt::WA_DeleteOnClose); + connect(this, &QProgressDialog::canceled, this, &QProgressDialog::close, Qt::UniqueConnection); } void progress_dialog::SignalFailure() const