summaryrefslogtreecommitdiffstats
path: root/src/yuzu/game_list.cpp
diff options
context:
space:
mode:
authorFranco M <francomaro@gmail.com>2023-11-05 01:28:16 +0100
committerGitHub <noreply@github.com>2023-11-05 01:28:16 +0100
commit728aca770317b3f86961c8669ba9ae5c68570d3f (patch)
tree29adffcb1d264cc16cacb478a8f6645ef6259b3b /src/yuzu/game_list.cpp
parentWe dont need that (diff)
parentMerge pull request #11952 from liamwhite/opus_stereo_count (diff)
downloadyuzu-728aca770317b3f86961c8669ba9ae5c68570d3f.tar
yuzu-728aca770317b3f86961c8669ba9ae5c68570d3f.tar.gz
yuzu-728aca770317b3f86961c8669ba9ae5c68570d3f.tar.bz2
yuzu-728aca770317b3f86961c8669ba9ae5c68570d3f.tar.lz
yuzu-728aca770317b3f86961c8669ba9ae5c68570d3f.tar.xz
yuzu-728aca770317b3f86961c8669ba9ae5c68570d3f.tar.zst
yuzu-728aca770317b3f86961c8669ba9ae5c68570d3f.zip
Diffstat (limited to 'src/yuzu/game_list.cpp')
-rw-r--r--src/yuzu/game_list.cpp26
1 files changed, 11 insertions, 15 deletions
diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp
index 90433e245..f294dc23d 100644
--- a/src/yuzu/game_list.cpp
+++ b/src/yuzu/game_list.cpp
@@ -380,7 +380,6 @@ void GameList::UnloadController() {
GameList::~GameList() {
UnloadController();
- emit ShouldCancelWorker();
}
void GameList::SetFilterFocus() {
@@ -397,6 +396,10 @@ void GameList::ClearFilter() {
search_field->clear();
}
+void GameList::WorkerEvent() {
+ current_worker->ProcessEvents(this);
+}
+
void GameList::AddDirEntry(GameListDir* entry_items) {
item_model->invisibleRootItem()->appendRow(entry_items);
tree_view->setExpanded(
@@ -828,28 +831,21 @@ void GameList::PopulateAsync(QVector<UISettings::GameDir>& game_dirs) {
tree_view->setColumnHidden(COLUMN_SIZE, !UISettings::values.show_size);
tree_view->setColumnHidden(COLUMN_PLAY_TIME, !UISettings::values.show_play_time);
- // Before deleting rows, cancel the worker so that it is not using them
- emit ShouldCancelWorker();
+ // Cancel any existing worker.
+ current_worker.reset();
// Delete any rows that might already exist if we're repopulating
item_model->removeRows(0, item_model->rowCount());
search_field->clear();
- GameListWorker* worker =
- new GameListWorker(vfs, provider, game_dirs, compatibility_list, play_time_manager, system);
+ current_worker = std::make_unique<GameListWorker>(vfs, provider, game_dirs, compatibility_list,
+ play_time_manager, system);
- connect(worker, &GameListWorker::EntryReady, this, &GameList::AddEntry, Qt::QueuedConnection);
- connect(worker, &GameListWorker::DirEntryReady, this, &GameList::AddDirEntry,
- Qt::QueuedConnection);
- connect(worker, &GameListWorker::Finished, this, &GameList::DonePopulating,
+ // Get events from the worker as data becomes available
+ connect(current_worker.get(), &GameListWorker::DataAvailable, this, &GameList::WorkerEvent,
Qt::QueuedConnection);
- // Use DirectConnection here because worker->Cancel() is thread-safe and we want it to
- // cancel without delay.
- connect(this, &GameList::ShouldCancelWorker, worker, &GameListWorker::Cancel,
- Qt::DirectConnection);
- QThreadPool::globalInstance()->start(worker);
- current_worker = std::move(worker);
+ QThreadPool::globalInstance()->start(current_worker.get());
}
void GameList::SaveInterfaceLayout() {