fix: Make sure library plugins are always initialized
This commit is contained in:
parent
f44b44a881
commit
5adeac6bbc
@ -2,6 +2,7 @@
|
||||
|
||||
#include <hex.hpp>
|
||||
#include <hex/api/plugin_manager.hpp>
|
||||
#include <hex/helpers/logger.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
@ -26,6 +27,11 @@
|
||||
|
||||
#define IMHEX_LIBRARY_SETUP_IMPL() \
|
||||
IMHEX_PLUGIN_VISIBILITY_PREFIX void initializeLibrary(); \
|
||||
static auto WOLV_TOKEN_CONCAT(libraryInitializer_, IMHEX_PLUGIN_NAME) = [] { \
|
||||
initializeLibrary(); \
|
||||
hex::log::info("Library plugin '{}' initialized successfully", WOLV_STRINGIFY(IMHEX_PLUGIN_NAME)); \
|
||||
return 0; \
|
||||
}(); \
|
||||
extern "C" [[gnu::visibility("default")]] void WOLV_TOKEN_CONCAT(forceLinkPlugin_, IMHEX_PLUGIN_NAME)() { \
|
||||
hex::PluginManager::addPlugin(hex::PluginFunctions { \
|
||||
nullptr, \
|
||||
|
@ -17,6 +17,8 @@
|
||||
namespace hex {
|
||||
|
||||
Plugin::Plugin(const std::fs::path &path) : m_path(path) {
|
||||
log::info("Loading plugin '{}'", wolv::util::toUTF8String(path.filename()));
|
||||
|
||||
#if defined(OS_WINDOWS)
|
||||
m_handle = uintptr_t(LoadLibraryW(path.c_str()));
|
||||
|
||||
@ -33,8 +35,6 @@ namespace hex {
|
||||
}
|
||||
#endif
|
||||
|
||||
log::info("Loaded plugin '{}'", wolv::util::toUTF8String(path.filename()));
|
||||
|
||||
m_functions.initializePluginFunction = getPluginFunction<PluginFunctions::InitializePluginFunc>("initializePlugin");
|
||||
m_functions.initializeLibraryFunction = getPluginFunction<PluginFunctions::InitializePluginFunc>("initializeLibrary");
|
||||
m_functions.getPluginNameFunction = getPluginFunction<PluginFunctions::GetPluginNameFunc>("getPluginName");
|
||||
@ -88,8 +88,6 @@ namespace hex {
|
||||
const auto pluginName = wolv::util::toUTF8String(m_path.filename());
|
||||
|
||||
if (this->isLibraryPlugin()) {
|
||||
m_functions.initializeLibraryFunction();
|
||||
log::info("Library plugin '{}' initialized successfully", pluginName);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user