1
0
mirror of synced 2025-02-17 10:58:34 +01:00

fix: Using cli arguments with statically linked plugins not working

This commit is contained in:
WerWolv 2024-02-01 11:40:27 +01:00
parent 7709f4e307
commit 4fd4b3dfad
2 changed files with 17 additions and 0 deletions

View File

@ -77,11 +77,14 @@ namespace hex {
[[nodiscard]] bool isLibraryPlugin() const;
[[nodiscard]] bool wasAddedManually() const;
private:
uintptr_t m_handle = 0;
std::fs::path m_path;
mutable bool m_initialized = false;
bool m_addedManually = false;
PluginFunctions m_functions = {};

View File

@ -55,6 +55,7 @@ namespace hex {
m_handle = 0;
m_functions = functions;
m_path = name;
m_addedManually = true;
}
@ -63,6 +64,7 @@ namespace hex {
other.m_handle = 0;
m_path = std::move(other.m_path);
m_addedManually = other.m_addedManually;
m_functions = other.m_functions;
other.m_functions = {};
@ -73,6 +75,7 @@ namespace hex {
other.m_handle = 0;
m_path = std::move(other.m_path);
m_addedManually = other.m_addedManually;
m_functions = other.m_functions;
other.m_functions = {};
@ -220,6 +223,11 @@ namespace hex {
m_functions.initializePluginFunction == nullptr;
}
bool Plugin::wasAddedManually() const {
return m_addedManually;
}
void *Plugin::getPluginFunction(const std::string &symbol) const {
@ -287,9 +295,15 @@ namespace hex {
// Unload plugins in reverse order
auto &plugins = getPlugins();
std::list<Plugin> savedPlugins;
while (!plugins.empty()) {
if (plugins.back().wasAddedManually())
savedPlugins.emplace_front(std::move(plugins.back()));
plugins.pop_back();
}
getPlugins() = std::move(savedPlugins);
}
void PluginManager::addPlugin(const std::string &name, hex::PluginFunctions functions) {