mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-26 09:25:59 +01:00
Unload plugins on compositor cleanup (#1662)
This commit is contained in:
parent
07b98952bc
commit
5c93f6947a
3 changed files with 13 additions and 2 deletions
|
@ -285,6 +285,10 @@ void CCompositor::cleanup() {
|
||||||
|
|
||||||
m_bIsShuttingDown = true;
|
m_bIsShuttingDown = true;
|
||||||
|
|
||||||
|
// unload all remaining plugins while the compositor is
|
||||||
|
// still in a normal working state.
|
||||||
|
g_pPluginSystem->unloadAllPlugins();
|
||||||
|
|
||||||
m_pLastFocus = nullptr;
|
m_pLastFocus = nullptr;
|
||||||
m_pLastWindow = nullptr;
|
m_pLastWindow = nullptr;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "PluginSystem.hpp"
|
#include "PluginSystem.hpp"
|
||||||
|
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
|
#include <ranges>
|
||||||
#include "../Compositor.hpp"
|
#include "../Compositor.hpp"
|
||||||
|
|
||||||
CPluginSystem::CPluginSystem() {
|
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; });
|
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) {
|
CPlugin* CPluginSystem::getPluginByPath(const std::string& path) {
|
||||||
for (auto& p : m_vLoadedPlugins) {
|
for (auto& p : m_vLoadedPlugins) {
|
||||||
if (p->path == path)
|
if (p->path == path)
|
||||||
|
|
|
@ -29,6 +29,7 @@ class CPluginSystem {
|
||||||
|
|
||||||
CPlugin* loadPlugin(const std::string& path);
|
CPlugin* loadPlugin(const std::string& path);
|
||||||
void unloadPlugin(const CPlugin* plugin, bool eject = false);
|
void unloadPlugin(const CPlugin* plugin, bool eject = false);
|
||||||
|
void unloadAllPlugins();
|
||||||
CPlugin* getPluginByPath(const std::string& path);
|
CPlugin* getPluginByPath(const std::string& path);
|
||||||
CPlugin* getPluginByHandle(HANDLE handle);
|
CPlugin* getPluginByHandle(HANDLE handle);
|
||||||
std::vector<CPlugin*> getAllPlugins();
|
std::vector<CPlugin*> getAllPlugins();
|
||||||
|
|
Loading…
Reference in a new issue