aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/yuzu/game_list_worker.h
diff options
context:
space:
mode:
authorLiam <[email protected]>2023-10-23 22:09:29 -0400
committerLiam <[email protected]>2023-10-23 23:06:07 -0400
commit79894152a8b2270f928644c37ef26f33eb44272e (patch)
treee64dfe4d710b0da3936dd7f52b3965a6a903137c /src/yuzu/game_list_worker.h
parent9274eaecd07f9e1fd2b0da1de2811e9fef22c4f3 (diff)
downloadyuzu-mainline-79894152a8b2270f928644c37ef26f33eb44272e.tar.gz
yuzu-mainline-79894152a8b2270f928644c37ef26f33eb44272e.zip
qt: fix game list shutdown crash
Diffstat (limited to 'src/yuzu/game_list_worker.h')
-rw-r--r--src/yuzu/game_list_worker.h35
1 files changed, 19 insertions, 16 deletions
diff --git a/src/yuzu/game_list_worker.h b/src/yuzu/game_list_worker.h
index 54dc05e30..d5990fcde 100644
--- a/src/yuzu/game_list_worker.h
+++ b/src/yuzu/game_list_worker.h
@@ -4,6 +4,7 @@
#pragma once
#include <atomic>
+#include <deque>
#include <memory>
#include <string>
@@ -20,6 +21,7 @@ namespace Core {
class System;
}
+class GameList;
class QStandardItem;
namespace FileSys {
@@ -46,24 +48,22 @@ public:
/// Starts the processing of directory tree information.
void run() override;
- /// Tells the worker that it should no longer continue processing. Thread-safe.
- void Cancel();
-
-signals:
+public:
/**
- * The `EntryReady` signal is emitted once an entry has been prepared and is ready
- * to be added to the game list.
- * @param entry_items a list with `QStandardItem`s that make up the columns of the new
- * entry.
+ * Synchronously processes any events queued by the worker.
+ *
+ * AddDirEntry is called on the game list for every discovered directory.
+ * AddEntry is called on the game list for every discovered program.
+ * DonePopulating is called on the game list when processing completes.
*/
- void DirEntryReady(GameListDir* entry_items);
- void EntryReady(QList<QStandardItem*> entry_items, GameListDir* parent_dir);
+ void ProcessEvents(GameList* game_list);
- /**
- * After the worker has traversed the game directory looking for entries, this signal is
- * emitted with a list of folders that should be watched for changes as well.
- */
- void Finished(QStringList watch_list);
+signals:
+ void DataAvailable();
+
+private:
+ template <typename F>
+ void RecordEvent(F&& func);
private:
void AddTitlesToGameList(GameListDir* parent_dir);
@@ -84,8 +84,11 @@ private:
QStringList watch_list;
- Common::Event processing_completed;
+ std::mutex lock;
+ std::condition_variable cv;
+ std::deque<std::function<void(GameList*)>> queued_events;
std::atomic_bool stop_requested = false;
+ Common::Event processing_completed;
Core::System& system;
};