From 94ad6e60721b0fe3556ec1be0d21a0e4dc3c8e3c Mon Sep 17 00:00:00 2001 From: WerWolv Date: Mon, 30 Oct 2023 16:39:57 +0100 Subject: [PATCH] fix: Crash on exit --- lib/libimhex/source/api/content_registry.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/libimhex/source/api/content_registry.cpp b/lib/libimhex/source/api/content_registry.cpp index cd493789e..23cd5a79e 100644 --- a/lib/libimhex/source/api/content_registry.cpp +++ b/lib/libimhex/source/api/content_registry.cpp @@ -986,7 +986,8 @@ namespace hex { } for (auto &service : getServices()) { - service.thread.detach(); + if (service.thread.joinable()) + service.thread.join(); } } @@ -997,7 +998,7 @@ namespace hex { impl::getServices().push_back(impl::Service { unlocalizedName, - std::jthread([callback](const std::stop_token &stopToken){ + std::jthread([callback = auto(callback)](const std::stop_token &stopToken){ while (!stopToken.stop_requested()) { callback(); std::this_thread::sleep_for(std::chrono::milliseconds(50));