From 190378bc33a2e57fdd48ceed43f75ed04a41b532 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Wed, 20 May 2026 18:51:06 +0200 Subject: [PATCH] Qt: fix batch progress bar value It was always one too early --- rpcs3/rpcs3qt/game_list_actions.cpp | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/rpcs3/rpcs3qt/game_list_actions.cpp b/rpcs3/rpcs3qt/game_list_actions.cpp index 13e9d8d29d..5e0b77a802 100644 --- a/rpcs3/rpcs3qt/game_list_actions.cpp +++ b/rpcs3/rpcs3qt/game_list_actions.cpp @@ -1030,11 +1030,9 @@ void game_list_actions::BatchActionBySerials(progress_dialog* pdlg, const std::s return false; } - if (action(serial)) + if (!action(serial)) { - const int done = index_ptr->load(); - pdlg->setLabelText(progressLabel.arg(done + 1).arg(serials_size)); - pdlg->SetValue(done + 1); + game_list_log.trace("Batch action for '%s' failed", serial); } (*index_ptr)++; @@ -1052,11 +1050,21 @@ void game_list_actions::BatchActionBySerials(progress_dialog* pdlg, const std::s indices.append(i); } - QFutureWatcher* future_watcher = new QFutureWatcher(m_game_list_frame); + QFutureWatcher* future_watcher = new QFutureWatcher(m_game_list_frame); - future_watcher->setFuture(QtConcurrent::map(std::move(indices), *iterate_over_serial)); + future_watcher->setFuture(QtConcurrent::mapped(std::move(indices), *iterate_over_serial)); - connect(future_watcher, &QFutureWatcher::finished, m_game_list_frame, [=, this]() + connect(future_watcher, &QFutureWatcher::resultReadyAt, m_game_list_frame, [=](int index) + { + if (future_watcher->resultAt(index)) + { + const int done = pdlg->value() + 1; + pdlg->setLabelText(progressLabel.arg(done).arg(serials_size)); + pdlg->SetValue(done); + } + }); + + connect(future_watcher, &QFutureWatcher::finished, m_game_list_frame, [=, this]() { pdlg->setLabelText(progressLabel.arg(index->load()).arg(serials_size)); pdlg->setCancelButtonText(tr("OK")); @@ -1092,6 +1100,10 @@ void game_list_actions::BatchActionBySerials(progress_dialog* pdlg, const std::s if ((*iterate_over_serial)(*index)) { + const int done = index->load(); + pdlg->setLabelText(progressLabel.arg(done).arg(serials_size)); + pdlg->SetValue(done); + QTimer::singleShot(1, m_game_list_frame, *periodic_func); return; }