pluginsystem: unload entire plugin before calling dlclose()

fixes #5689
This commit is contained in:
Vaxry 2024-04-22 15:46:43 +01:00
parent e1644e91ea
commit 450343b7b8

View file

@ -119,11 +119,16 @@ void CPluginSystem::unloadPlugin(const CPlugin* plugin, bool eject) {
g_pConfigManager->removePluginConfig(plugin->m_pHandle); g_pConfigManager->removePluginConfig(plugin->m_pHandle);
dlclose(plugin->m_pHandle); // save these two for dlclose and a log,
// as erase_if will kill the pointer
const auto PLNAME = plugin->name;
const auto PLHANDLE = plugin->m_pHandle;
Debug::log(LOG, " [PluginSystem] Plugin {} unloaded.", plugin->name); std::erase_if(m_vLoadedPlugins, [&](const auto& other) { return other->m_pHandle == PLHANDLE; });
std::erase_if(m_vLoadedPlugins, [&](const auto& other) { return other->m_pHandle == plugin->m_pHandle; }); dlclose(PLHANDLE);
Debug::log(LOG, " [PluginSystem] Plugin {} unloaded.", PLNAME);
// reload config to fix some stuf like e.g. unloadedPluginVars // reload config to fix some stuf like e.g. unloadedPluginVars
g_pConfigManager->m_bForceReload = true; g_pConfigManager->m_bForceReload = true;