From 0f00bb77fe3058ac9a8064d85663eec922a15042 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Mon, 11 Mar 2024 22:10:07 +0100 Subject: [PATCH] Qt: only connect refresh watcher signals once --- rpcs3/rpcs3qt/game_list_frame.cpp | 51 ++++++++++++------------------- 1 file changed, 20 insertions(+), 31 deletions(-) diff --git a/rpcs3/rpcs3qt/game_list_frame.cpp b/rpcs3/rpcs3qt/game_list_frame.cpp index 13c1b92a42..665cbbd895 100644 --- a/rpcs3/rpcs3qt/game_list_frame.cpp +++ b/rpcs3/rpcs3qt/game_list_frame.cpp @@ -162,7 +162,27 @@ game_list_frame::game_list_frame(std::shared_ptr gui_settings, std m_game_data.clear(); m_serials.clear(); m_games.pop_all(); + + if (m_progress_dialog) + { + m_progress_dialog->accept(); + m_progress_dialog = nullptr; + } }); + connect(&m_refresh_watcher, &QFutureWatcher::progressRangeChanged, this, [this](int minimum, int maximum) + { + if (m_progress_dialog) + { + m_progress_dialog->SetRange(minimum, maximum); + } + }, Qt::QueuedConnection); + connect(&m_refresh_watcher, &QFutureWatcher::progressValueChanged, this, [this](int value) + { + if (m_progress_dialog) + { + m_progress_dialog->SetValue(value); + } + }, Qt::QueuedConnection); connect(m_game_list, &QTableWidget::customContextMenuRequested, this, &game_list_frame::ShowContextMenu); connect(m_game_list, &QTableWidget::itemSelectionChanged, this, &game_list_frame::ItemSelectionChangedSlot); @@ -317,37 +337,6 @@ void game_list_frame::Refresh(const bool from_drive, const bool scroll_after) m_progress_dialog = new progress_dialog(tr("Loading games"), tr("Loading games, please wait..."), tr("Cancel"), 0, 0, true, this, Qt::Dialog | Qt::WindowTitleHint | Qt::CustomizeWindowHint); - connect(&m_refresh_watcher, &QFutureWatcher::progressRangeChanged, this, [this](int minimum, int maximum) - { - if (m_progress_dialog) - { - m_progress_dialog->SetRange(minimum, maximum); - } - }, Qt::QueuedConnection); - connect(&m_refresh_watcher, &QFutureWatcher::progressValueChanged, this, [this](int value) - { - if (m_progress_dialog) - { - 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;