diff --git a/lib/libimhex/include/hex/api/event.hpp b/lib/libimhex/include/hex/api/event.hpp index e5b5d5601..6214f287a 100644 --- a/lib/libimhex/include/hex/api/event.hpp +++ b/lib/libimhex/include/hex/api/event.hpp @@ -95,6 +95,11 @@ namespace hex { } } + static void clear() noexcept { + s_events.clear(); + s_tokenStore.clear(); + } + private: static std::map s_tokenStore; static EventList s_events; diff --git a/main/source/init/tasks.cpp b/main/source/init/tasks.cpp index cae18f373..61cabab2f 100644 --- a/main/source/init/tasks.cpp +++ b/main/source/init/tasks.cpp @@ -163,6 +163,8 @@ namespace hex::init { } bool deleteSharedData() { + EventManager::clear(); + while (ImHexApi::Provider::isValid()) ImHexApi::Provider::remove(ImHexApi::Provider::get()); ContentRegistry::Provider::getEntries().clear(); diff --git a/main/source/window/window.cpp b/main/source/window/window.cpp index 6041f1e47..7bbf6535b 100644 --- a/main/source/window/window.cpp +++ b/main/source/window/window.cpp @@ -160,14 +160,14 @@ namespace hex { } Window::~Window() { - this->exitImGui(); - this->exitGLFW(); - EventManager::unsubscribe(this); EventManager::unsubscribe(this); EventManager::unsubscribe(this); EventManager::unsubscribe(this); EventManager::unsubscribe(this); + + this->exitImGui(); + this->exitGLFW(); } void Window::loop() {