From cf601586fc58f6d17ac0925b3a4a6fd72bb2a734 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Wed, 28 Dec 2022 23:06:27 +0100 Subject: [PATCH] fix: Deadlock when loading recent files --- lib/libimhex/include/hex/api/task.hpp | 2 +- lib/libimhex/source/api/task.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/libimhex/include/hex/api/task.hpp b/lib/libimhex/include/hex/api/task.hpp index 3eb7285e2..5af6570ca 100644 --- a/lib/libimhex/include/hex/api/task.hpp +++ b/lib/libimhex/include/hex/api/task.hpp @@ -110,7 +110,7 @@ namespace hex { static void runWhenTasksFinished(const std::function &function); private: - static std::mutex s_deferredCallsMutex; + static std::mutex s_deferredCallsMutex, s_tasksFinishedMutex; static std::list> s_tasks; static std::list> s_taskQueue; diff --git a/lib/libimhex/source/api/task.cpp b/lib/libimhex/source/api/task.cpp index 3d208a5de..2aac5dc68 100644 --- a/lib/libimhex/source/api/task.cpp +++ b/lib/libimhex/source/api/task.cpp @@ -8,7 +8,7 @@ namespace hex { - std::mutex TaskManager::s_deferredCallsMutex; + std::mutex TaskManager::s_deferredCallsMutex, TaskManager::s_tasksFinishedMutex; std::list> TaskManager::s_tasks, TaskManager::s_taskQueue; std::list> TaskManager::s_deferredCalls; @@ -288,7 +288,7 @@ namespace hex { } void TaskManager::runWhenTasksFinished(const std::function &function) { - std::scoped_lock lock(s_deferredCallsMutex); + std::scoped_lock lock(s_tasksFinishedMutex); s_tasksFinishedCallbacks.push_back(function); }