aboutsummaryrefslogtreecommitdiff
path: root/src/qt_common/game_list/worker.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qt_common/game_list/worker.cpp')
-rw-r--r--src/qt_common/game_list/worker.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/qt_common/game_list/worker.cpp b/src/qt_common/game_list/worker.cpp
index 14afe2f276..d18f84089a 100644
--- a/src/qt_common/game_list/worker.cpp
+++ b/src/qt_common/game_list/worker.cpp
@@ -313,12 +313,18 @@ GameListWorker::GameListWorker(FileSys::VirtualFilesystem vfs_,
GameListWorker::~GameListWorker() {
this->disconnect();
- stop_requested.store(true);
- processing_completed.Wait();
+ Stop();
+}
+
+void GameListWorker::Stop() {
+ if (!stop_requested.exchange(true)) {
+ processing_completed.Wait();
+ }
}
void GameListWorker::ProcessEvents(GameListModel* model) {
- while (true) {
+ // An event may spin a nested event loop that replaces this worker, in which case stop.
+ while (model->current_worker.get() == this) {
std::function<void(GameListModel*)> func;
{
// Lock queue to protect concurrent modification.