From fe69610cb71010ca88999278adfacfe7917419ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Thu, 15 Aug 2024 00:29:15 -0300 Subject: [PATCH] Fix crash when reloading plugins and triggering subscribed events. --- src/tools/ecode/plugins/formatter/formatterplugin.cpp | 3 ++- src/tools/ecode/plugins/lsp/lspclientplugin.cpp | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/tools/ecode/plugins/formatter/formatterplugin.cpp b/src/tools/ecode/plugins/formatter/formatterplugin.cpp index 997e5c80e..76135efde 100644 --- a/src/tools/ecode/plugins/formatter/formatterplugin.cpp +++ b/src/tools/ecode/plugins/formatter/formatterplugin.cpp @@ -59,7 +59,8 @@ FormatterPlugin::~FormatterPlugin() { if ( editor.first->hasDocument() ) editor.first->getDocument().removeCommand( kb.first ); } - + for ( auto listener : editor.second ) + editor.first->removeEventListener( listener ); editor.first->unregisterPlugin( this ); } } diff --git a/src/tools/ecode/plugins/lsp/lspclientplugin.cpp b/src/tools/ecode/plugins/lsp/lspclientplugin.cpp index d8280b040..db0b3c701 100644 --- a/src/tools/ecode/plugins/lsp/lspclientplugin.cpp +++ b/src/tools/ecode/plugins/lsp/lspclientplugin.cpp @@ -155,6 +155,8 @@ LSPClientPlugin::~LSPClientPlugin() { if ( editor.first->hasDocument() ) editor.first->getDocument().removeCommand( kb.first ); } + for ( auto listener : editor.second ) + editor.first->removeEventListener( listener ); editor.first->unregisterPlugin( this ); } if ( nullptr == mManager->getSplitter() )