From 2390b19706dcc37e6155c964b3d5b850fef0fa0e Mon Sep 17 00:00:00 2001 From: Don HO Date: Wed, 27 Dec 2017 14:55:35 +0100 Subject: [PATCH] Fix a crash bug due to eventual disordered notifications sent to plugins The Access Violation while closing Notepad++: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/3961 could be due to SCN_UPDATEUI sending after NPPN_SHUTDOWN, that makes plugins treat SCN_UPDATEUI on the released handle. To avoid such situation, once NPPN_SHUTDOWN has been sent, no more message will be sent to plugin. Fixes #3961, fixes #4021 --- PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp | 4 ++++ PowerEditor/src/MISC/PluginsManager/PluginsManager.h | 1 + 2 files changed, 5 insertions(+) diff --git a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp index 5cfb363de..f94371e07 100644 --- a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp +++ b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp @@ -564,6 +564,10 @@ void PluginsManager::runPluginCommand(const TCHAR *pluginName, int commandID) void PluginsManager::notify(const SCNotification *notification) { + if (_noMoreNotification) // this boolean should be enabled after NPPN_SHUTDOWN has been sent + return; + _noMoreNotification = notification->nmhdr.code == NPPN_SHUTDOWN; + for (size_t i = 0, len = _pluginInfos.size() ; i < len ; ++i) { if (_pluginInfos[i]->_hLib) diff --git a/PowerEditor/src/MISC/PluginsManager/PluginsManager.h b/PowerEditor/src/MISC/PluginsManager/PluginsManager.h index 28d9832d4..b2c48fdf2 100644 --- a/PowerEditor/src/MISC/PluginsManager/PluginsManager.h +++ b/PowerEditor/src/MISC/PluginsManager/PluginsManager.h @@ -137,6 +137,7 @@ private: bool _isDisabled = false; IDAllocator _dynamicIDAlloc; IDAllocator _markerAlloc; + bool _noMoreNotification = false; void pluginCrashAlert(const TCHAR *pluginName, const TCHAR *funcSignature) {