From 037d77f28eb8b13182401c55696c1ef2a8757e44 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Tue, 9 Jan 2024 10:54:53 +0100 Subject: [PATCH] impr: Improve plugin unload logging --- lib/libimhex/include/hex/plugin.hpp | 4 ++-- lib/libimhex/source/api/plugin_manager.cpp | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/libimhex/include/hex/plugin.hpp b/lib/libimhex/include/hex/plugin.hpp index 3b2bfcc60..076729d58 100644 --- a/lib/libimhex/include/hex/plugin.hpp +++ b/lib/libimhex/include/hex/plugin.hpp @@ -27,7 +27,7 @@ #define IMHEX_LIBRARY_SETUP(name) IMHEX_LIBRARY_SETUP_IMPL(name) #define IMHEX_LIBRARY_SETUP_IMPL(name) \ - namespace { static struct EXIT_HANDLER { ~EXIT_HANDLER() { hex::log::info("Unloading library '{}'", name); } } HANDLER; } \ + namespace { static struct EXIT_HANDLER { ~EXIT_HANDLER() { hex::log::info("Unloaded library '{}'", name); } } HANDLER; } \ IMHEX_PLUGIN_VISIBILITY_PREFIX void initializeLibrary(); \ static auto WOLV_TOKEN_CONCAT(libraryInitializer_, IMHEX_PLUGIN_NAME) = [] { \ initializeLibrary(); \ @@ -54,7 +54,7 @@ IMHEX_PLUGIN_VISIBILITY_PREFIX void initializeLibrary() #define IMHEX_PLUGIN_SETUP_IMPL(name, author, description) \ - namespace { static struct EXIT_HANDLER { ~EXIT_HANDLER() { hex::log::info("Unloading plugin '{}'", name); } } HANDLER; } \ + namespace { static struct EXIT_HANDLER { ~EXIT_HANDLER() { hex::log::info("Unloaded plugin '{}'", name); } } HANDLER; } \ IMHEX_PLUGIN_VISIBILITY_PREFIX const char *getPluginName() { return name; } \ IMHEX_PLUGIN_VISIBILITY_PREFIX const char *getPluginAuthor() { return author; } \ IMHEX_PLUGIN_VISIBILITY_PREFIX const char *getPluginDescription() { return description; } \ diff --git a/lib/libimhex/source/api/plugin_manager.cpp b/lib/libimhex/source/api/plugin_manager.cpp index 2f23286ba..4107c118b 100644 --- a/lib/libimhex/source/api/plugin_manager.cpp +++ b/lib/libimhex/source/api/plugin_manager.cpp @@ -260,6 +260,11 @@ namespace hex { auto &plugins = getPlugins(); const auto pluginCount = plugins.size(); for (size_t i = 0; i < pluginCount; i++) { + auto &plugin = plugins[pluginCount - 1 - i]; + if (plugin.isLoaded()) { + log::info("Trying to unload plugin '{}'", plugin.getPluginName()); + } + plugins.pop_back(); } }