From f9909dab984ec427c19464563c5c82fe31204271 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Fri, 30 Jun 2023 13:40:16 +0200 Subject: [PATCH] fix: Properly clear all global registries --- lib/libimhex/include/hex/api/imhex_api.hpp | 4 ++-- lib/libimhex/source/api/imhex_api.cpp | 10 +++++----- main/source/init/tasks.cpp | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/libimhex/include/hex/api/imhex_api.hpp b/lib/libimhex/include/hex/api/imhex_api.hpp index eb8e3603e..db12afc97 100644 --- a/lib/libimhex/include/hex/api/imhex_api.hpp +++ b/lib/libimhex/include/hex/api/imhex_api.hpp @@ -460,7 +460,7 @@ namespace hex { * @brief Gets the current custom font path * @return The current custom font path */ - const std::filesystem::path &getCustomFontPath(); + std::filesystem::path &getCustomFontPath(); /** * @brief Gets the current font size @@ -486,7 +486,7 @@ namespace hex { * @brief Gets the currently set additional folder paths * @return The currently set additional folder paths */ - const std::vector &getAdditionalFolderPaths(); + std::vector &getAdditionalFolderPaths(); /** * @brief Sets the additional folder paths diff --git a/lib/libimhex/source/api/imhex_api.cpp b/lib/libimhex/source/api/imhex_api.cpp index 901c7068a..942c1e27d 100644 --- a/lib/libimhex/source/api/imhex_api.cpp +++ b/lib/libimhex/source/api/imhex_api.cpp @@ -480,7 +480,7 @@ namespace hex { return initArgs; } - const std::fs::path &getCustomFontPath() { + std::fs::path &getCustomFontPath() { return impl::s_customFontPath; } @@ -504,13 +504,13 @@ namespace hex { } - static std::vector s_additionalFolderPaths; - const std::vector &getAdditionalFolderPaths() { - return s_additionalFolderPaths; + std::vector &getAdditionalFolderPaths() { + static std::vector additionalFolderPaths; + return additionalFolderPaths; } void setAdditionalFolderPaths(const std::vector &paths) { - s_additionalFolderPaths = paths; + getAdditionalFolderPaths() = paths; } diff --git a/main/source/init/tasks.cpp b/main/source/init/tasks.cpp index 63b7e55b2..3c356017a 100644 --- a/main/source/init/tasks.cpp +++ b/main/source/init/tasks.cpp @@ -325,6 +325,8 @@ namespace hex::init { ImHexApi::HexEditor::impl::getForegroundHighlightingFunctions().clear(); ImHexApi::HexEditor::impl::getTooltips().clear(); ImHexApi::HexEditor::impl::getTooltipFunctions().clear(); + ImHexApi::System::getAdditionalFolderPaths().clear(); + ImHexApi::System::getCustomFontPath().clear(); ContentRegistry::Settings::impl::getEntries().clear(); ContentRegistry::Settings::impl::getSettingsData().clear(); @@ -375,7 +377,6 @@ namespace hex::init { ThemeManager::reset(); - ProjectFile::getHandlers().clear(); ProjectFile::getProviderHandlers().clear(); ProjectFile::setProjectFunctions(nullptr, nullptr);