diff --git a/lib/libimhex/source/api/imhex_api.cpp b/lib/libimhex/source/api/imhex_api.cpp index e5071e477..3a4a17c58 100644 --- a/lib/libimhex/source/api/imhex_api.cpp +++ b/lib/libimhex/source/api/imhex_api.cpp @@ -172,15 +172,17 @@ namespace hex { return { unlocalizedName, maxValue }; } - - std::vector> s_deferredCalls; - void doLater(const std::function &function) { + static std::mutex tasksMutex; + std::scoped_lock lock(tasksMutex); + getDeferredCalls().push_back(function); } std::vector> &getDeferredCalls() { - return s_deferredCalls; + static std::vector> deferredCalls; + + return deferredCalls; } }