fix: Make sure plugins are unloaded in opposite load order
This commit is contained in:
parent
09300c209f
commit
f9ab16049b
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <hex/helpers/logger.hpp>
|
#include <hex/helpers/logger.hpp>
|
||||||
#include <hex/helpers/fmt.hpp>
|
#include <hex/helpers/fmt.hpp>
|
||||||
|
#include <hex/helpers/utils.hpp>
|
||||||
|
|
||||||
#include <wolv/utils/string.hpp>
|
#include <wolv/utils/string.hpp>
|
||||||
|
|
||||||
@ -89,6 +90,7 @@ namespace hex {
|
|||||||
const auto pluginName = wolv::util::toUTF8String(m_path.filename());
|
const auto pluginName = wolv::util::toUTF8String(m_path.filename());
|
||||||
|
|
||||||
if (this->isLibraryPlugin()) {
|
if (this->isLibraryPlugin()) {
|
||||||
|
m_initialized = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,8 +244,19 @@ namespace hex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PluginManager::unload() {
|
void PluginManager::unload() {
|
||||||
getPlugins().clear();
|
|
||||||
getPluginPaths().clear();
|
getPluginPaths().clear();
|
||||||
|
|
||||||
|
// Unload plugins in reverse order
|
||||||
|
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("Unloading plugin '{}'", plugin.getPluginName());
|
||||||
|
}
|
||||||
|
|
||||||
|
plugins.pop_back();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PluginManager::reload() {
|
void PluginManager::reload() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user