From ace25d353b0241d1a5f0ae26b488065d9b39b277 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Wed, 3 Aug 2022 10:45:50 +0200 Subject: [PATCH] fix: GLFW error on exit --- lib/libimhex/include/hex/api/event.hpp | 5 +++++ main/source/init/tasks.cpp | 2 ++ main/source/window/window.cpp | 6 +++--- 3 files changed, 10 insertions(+), 3 deletions(-) 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() {