X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/d61fa7a7d848f470abd5b5df804624b258e8416b..367181dd32e2f94d68f3f040bd9d9a20ba1250c3:/projects/stargazer/plugin_mgr.cpp diff --git a/projects/stargazer/plugin_mgr.cpp b/projects/stargazer/plugin_mgr.cpp index 5346db8b..b87ab277 100644 --- a/projects/stargazer/plugin_mgr.cpp +++ b/projects/stargazer/plugin_mgr.cpp @@ -97,23 +97,7 @@ PluginManager::PluginManager(const SETTINGS_IMPL& settings, PluginManager::~PluginManager() { - std::sort(m_modules.begin(), m_modules.end(), StopModCmp); - for (size_t i = 0; i < m_modules.size(); ++i) - { - PLUGIN & plugin = m_modules[i]->GetPlugin(); - if (m_modules[i]->Stop()) - { - m_log("Failed to stop module '%s': '%s'", plugin.GetVersion().c_str(), - plugin.GetStrError().c_str()); - printfd(__FILE__, "Failed to stop module '%s': '%s'\n", plugin.GetVersion().c_str(), - plugin.GetStrError().c_str()); - } - else - { - m_log("Module '%s' stopped successfully.", plugin.GetVersion().c_str()); - printfd(__FILE__, "Module '%s' stopped successfully.\n", plugin.GetVersion().c_str()); - } - } + stop(); for (size_t i = 0; i < m_modules.size(); ++i) delete m_modules[i]; } @@ -132,3 +116,26 @@ void PluginManager::reload() } } } + +void PluginManager::stop() +{ + std::sort(m_modules.begin(), m_modules.end(), StopModCmp); + for (size_t i = 0; i < m_modules.size(); ++i) + { + if (!m_modules[i]->IsRunning()) + continue; + PLUGIN & plugin = m_modules[i]->GetPlugin(); + if (m_modules[i]->Stop()) + { + m_log("Failed to stop module '%s': '%s'", plugin.GetVersion().c_str(), + plugin.GetStrError().c_str()); + printfd(__FILE__, "Failed to stop module '%s': '%s'\n", plugin.GetVersion().c_str(), + plugin.GetStrError().c_str()); + } + else + { + m_log("Module '%s' stopped successfully.", plugin.GetVersion().c_str()); + printfd(__FILE__, "Module '%s' stopped successfully.\n", plugin.GetVersion().c_str()); + } + } +}