summaryrefslogtreecommitdiff
path: root/src/plugins/PluginSystem.cpp
diff options
context:
space:
mode:
authorStanisław Zagórowski <hasohasacz@gmail.com>2023-03-01 00:11:49 +0100
committerGitHub <noreply@github.com>2023-02-28 23:11:49 +0000
commit5c93f6947a04163c6ea8299e8721b923bea2fb9f (patch)
tree487bd6701c7539d0170b12217b7842c69c700af8 /src/plugins/PluginSystem.cpp
parent07b98952bc09f61d85895c49504b681de8687975 (diff)
Unload plugins on compositor cleanup (#1662)
Diffstat (limited to 'src/plugins/PluginSystem.cpp')
-rw-r--r--src/plugins/PluginSystem.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/plugins/PluginSystem.cpp b/src/plugins/PluginSystem.cpp
index 5b15782d..73de9bf5 100644
--- a/src/plugins/PluginSystem.cpp
+++ b/src/plugins/PluginSystem.cpp
@@ -1,6 +1,7 @@
#include "PluginSystem.hpp"
#include <dlfcn.h>
+#include <ranges>
#include "../Compositor.hpp"
CPluginSystem::CPluginSystem() {
@@ -113,6 +114,11 @@ void CPluginSystem::unloadPlugin(const CPlugin* plugin, bool eject) {
std::erase_if(m_vLoadedPlugins, [&](const auto& other) { return other->m_pHandle == plugin->m_pHandle; });
}
+void CPluginSystem::unloadAllPlugins() {
+ for (auto& p : m_vLoadedPlugins | std::views::reverse)
+ unloadPlugin(p.get(), false); // Unload remaining plugins gracefully
+}
+
CPlugin* CPluginSystem::getPluginByPath(const std::string& path) {
for (auto& p : m_vLoadedPlugins) {
if (p->path == path)
@@ -136,4 +142,4 @@ std::vector<CPlugin*> CPluginSystem::getAllPlugins() {
for (size_t i = 0; i < m_vLoadedPlugins.size(); ++i)
results[i] = m_vLoadedPlugins[i].get();
return results;
-} \ No newline at end of file
+}