From c35ea228e467aba3b96833f12c9e305caec09647 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Fri, 10 Nov 2023 21:03:31 +0100 Subject: [PATCH] fix: Crash when trying to close providers --- lib/libimhex/include/hex/api/imhex_api.hpp | 2 +- lib/libimhex/source/api/imhex_api.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/libimhex/include/hex/api/imhex_api.hpp b/lib/libimhex/include/hex/api/imhex_api.hpp index ac6e833e7..374c89e71 100644 --- a/lib/libimhex/include/hex/api/imhex_api.hpp +++ b/lib/libimhex/include/hex/api/imhex_api.hpp @@ -74,7 +74,7 @@ namespace hex { std::map &getTooltips(); std::map &getTooltipFunctions(); - void setCurrentSelection(std::optional region); + void setCurrentSelection(const std::optional ®ion); } /** diff --git a/lib/libimhex/source/api/imhex_api.cpp b/lib/libimhex/source/api/imhex_api.cpp index 8864cc2a8..afbd4e766 100644 --- a/lib/libimhex/source/api/imhex_api.cpp +++ b/lib/libimhex/source/api/imhex_api.cpp @@ -70,8 +70,8 @@ namespace hex { } static std::optional s_currentSelection; - void setCurrentSelection(std::optional region) { - s_currentSelection = std::move(region); + void setCurrentSelection(const std::optional ®ion) { + s_currentSelection = region; } } @@ -353,6 +353,7 @@ namespace hex { TaskManager::runWhenTasksFinished([provider] { EventManager::post(provider); + std::erase(impl::s_closingProviders, provider); delete provider; }); }