pluginsystem: fix crash when unloading plugin hyprctl commands (#12821)
This commit is contained in:
parent
17bc3b83db
commit
922e53c68c
3 changed files with 6 additions and 4 deletions
|
|
@ -407,7 +407,7 @@ APICALL bool HyprlandAPI::unregisterHyprCtlCommand(HANDLE handle, SP<SHyprCtlCom
|
|||
if (!PLUGIN)
|
||||
return false;
|
||||
|
||||
std::erase(PLUGIN->m_registeredHyprctlCommands, cmd);
|
||||
std::erase_if(PLUGIN->m_registeredHyprctlCommands, [&](const auto& other) { return !other || other == cmd; });
|
||||
g_pHyprCtl->unregisterCommand(cmd);
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -171,8 +171,10 @@ void CPluginSystem::unloadPlugin(const CPlugin* plugin, bool eject) {
|
|||
HyprlandAPI::removeDispatcher(plugin->m_handle, d);
|
||||
|
||||
const auto rhc = plugin->m_registeredHyprctlCommands;
|
||||
for (auto const& c : rhc)
|
||||
HyprlandAPI::unregisterHyprCtlCommand(plugin->m_handle, c);
|
||||
for (auto const& c : rhc) {
|
||||
if (const auto sp = c.lock())
|
||||
HyprlandAPI::unregisterHyprCtlCommand(plugin->m_handle, sp);
|
||||
}
|
||||
|
||||
g_pConfigManager->removePluginConfig(plugin->m_handle);
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class CPlugin {
|
|||
std::vector<IHyprWindowDecoration*> m_registeredDecorations;
|
||||
std::vector<std::pair<std::string, WP<HOOK_CALLBACK_FN>>> m_registeredCallbacks;
|
||||
std::vector<std::string> m_registeredDispatchers;
|
||||
std::vector<SP<SHyprCtlCommand>> m_registeredHyprctlCommands;
|
||||
std::vector<WP<SHyprCtlCommand>> m_registeredHyprctlCommands;
|
||||
};
|
||||
|
||||
class CPluginSystem {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue