diff options
| author | 2023-10-13 09:29:13 -0400 | |
|---|---|---|
| committer | 2023-10-13 09:29:13 -0400 | |
| commit | 1a4874e178860d723760d98be337cd4640b06a30 (patch) | |
| tree | afe20068da407a90e3ec5b38e3d8ae02a5afb2cd | |
| parent | Merge pull request #11766 from liamwhite/open-sesame (diff) | |
| parent | qt: ensure worker cancellation is complete before clearing (diff) | |
| download | yuzu-1a4874e178860d723760d98be337cd4640b06a30.tar.gz yuzu-1a4874e178860d723760d98be337cd4640b06a30.tar.xz yuzu-1a4874e178860d723760d98be337cd4640b06a30.zip | |
Merge pull request #11769 from liamwhite/qt-ownership-issue
qt: ensure worker cancellation is complete before clearing
| -rw-r--r-- | src/yuzu/game_list.cpp | 5 | ||||
| -rw-r--r-- | src/yuzu/game_list_worker.cpp | 7 | ||||
| -rw-r--r-- | src/yuzu/game_list_worker.h | 5 |
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) { | |||
| 293 | void GameListWorker::ScanFileSystem(ScanTarget target, const std::string& dir_path, bool deep_scan, | 293 | void 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 | ||
| 401 | void GameListWorker::run() { | 401 | void 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 | ||
| 432 | void GameListWorker::Cancel() { | 432 | void 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 | }; |