summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Liam2023-10-12 21:07:49 -0400
committerGravatar Liam2023-10-12 21:07:49 -0400
commitfaa6c35e78dd0c843de15e08e91211625bb1df67 (patch)
treed9197e8b25c0c99b627655a1c104eb4eb694e5f2
parentMerge pull request #11746 from liamwhite/relr (diff)
downloadyuzu-faa6c35e78dd0c843de15e08e91211625bb1df67.tar.gz
yuzu-faa6c35e78dd0c843de15e08e91211625bb1df67.tar.xz
yuzu-faa6c35e78dd0c843de15e08e91211625bb1df67.zip
qt: ensure worker cancellation is complete before clearing
Diffstat (limited to '')
-rw-r--r--src/yuzu/game_list.cpp5
-rw-r--r--src/yuzu/game_list_worker.cpp7
-rw-r--r--src/yuzu/game_list_worker.h5
3 files changed, 11 insertions, 6 deletions
diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp
index 74f48031a..2bb1a0239 100644
--- a/src/yuzu/game_list.cpp
+++ b/src/yuzu/game_list.cpp
@@ -826,12 +826,13 @@ void GameList::PopulateAsync(QVector<UISettings::GameDir>& game_dirs) {
826 tree_view->setColumnHidden(COLUMN_SIZE, !UISettings::values.show_size); 826 tree_view->setColumnHidden(COLUMN_SIZE, !UISettings::values.show_size);
827 tree_view->setColumnHidden(COLUMN_PLAY_TIME, !UISettings::values.show_play_time); 827 tree_view->setColumnHidden(COLUMN_PLAY_TIME, !UISettings::values.show_play_time);
828 828
829 // Before deleting rows, cancel the worker so that it is not using them
830 emit ShouldCancelWorker();
831
829 // Delete any rows that might already exist if we're repopulating 832 // Delete any rows that might already exist if we're repopulating
830 item_model->removeRows(0, item_model->rowCount()); 833 item_model->removeRows(0, item_model->rowCount());
831 search_field->clear(); 834 search_field->clear();
832 835
833 emit ShouldCancelWorker();
834
835 GameListWorker* worker = 836 GameListWorker* worker =
836 new GameListWorker(vfs, provider, game_dirs, compatibility_list, play_time_manager, system); 837 new GameListWorker(vfs, provider, game_dirs, compatibility_list, play_time_manager, system);
837 838
diff --git a/src/yuzu/game_list_worker.cpp b/src/yuzu/game_list_worker.cpp
index 588f1dd6e..077ced12b 100644
--- a/src/yuzu/game_list_worker.cpp
+++ b/src/yuzu/game_list_worker.cpp
@@ -293,7 +293,7 @@ void GameListWorker::AddTitlesToGameList(GameListDir* parent_dir) {
293void GameListWorker::ScanFileSystem(ScanTarget target, const std::string& dir_path, bool deep_scan, 293void GameListWorker::ScanFileSystem(ScanTarget target, const std::string& dir_path, bool deep_scan,
294 GameListDir* parent_dir) { 294 GameListDir* parent_dir) {
295 const auto callback = [this, target, parent_dir](const std::filesystem::path& path) -> bool { 295 const auto callback = [this, target, parent_dir](const std::filesystem::path& path) -> bool {
296 if (stop_processing) { 296 if (stop_requested) {
297 // Breaks the callback loop. 297 // Breaks the callback loop.
298 return false; 298 return false;
299 } 299 }
@@ -399,7 +399,6 @@ void GameListWorker::ScanFileSystem(ScanTarget target, const std::string& dir_pa
399} 399}
400 400
401void GameListWorker::run() { 401void GameListWorker::run() {
402 stop_processing = false;
403 provider->ClearAllEntries(); 402 provider->ClearAllEntries();
404 403
405 for (UISettings::GameDir& game_dir : game_dirs) { 404 for (UISettings::GameDir& game_dir : game_dirs) {
@@ -427,9 +426,11 @@ void GameListWorker::run() {
427 } 426 }
428 427
429 emit Finished(watch_list); 428 emit Finished(watch_list);
429 processing_completed.Set();
430} 430}
431 431
432void GameListWorker::Cancel() { 432void GameListWorker::Cancel() {
433 this->disconnect(); 433 this->disconnect();
434 stop_processing = true; 434 stop_requested.store(true);
435 processing_completed.Wait();
435} 436}
diff --git a/src/yuzu/game_list_worker.h b/src/yuzu/game_list_worker.h
index 2bb0a0cb6..54dc05e30 100644
--- a/src/yuzu/game_list_worker.h
+++ b/src/yuzu/game_list_worker.h
@@ -12,6 +12,7 @@
12#include <QRunnable> 12#include <QRunnable>
13#include <QString> 13#include <QString>
14 14
15#include "common/thread.h"
15#include "yuzu/compatibility_list.h" 16#include "yuzu/compatibility_list.h"
16#include "yuzu/play_time_manager.h" 17#include "yuzu/play_time_manager.h"
17 18
@@ -82,7 +83,9 @@ private:
82 const PlayTime::PlayTimeManager& play_time_manager; 83 const PlayTime::PlayTimeManager& play_time_manager;
83 84
84 QStringList watch_list; 85 QStringList watch_list;
85 std::atomic_bool stop_processing; 86
87 Common::Event processing_completed;
88 std::atomic_bool stop_requested = false;
86 89
87 Core::System& system; 90 Core::System& system;
88}; 91};