diff --git a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp index cfdb15f1c..5a4413979 100644 --- a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp +++ b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp @@ -605,7 +605,36 @@ void PluginsManager::runPluginCommand(const TCHAR *pluginName, int commandID) } } +// send the notification to a specific plugin +void PluginsManager::notify(size_t indexPluginInfo, const SCNotification *notification) +{ + if (indexPluginInfo >= _pluginInfos.size()) + return; + if (_pluginInfos[indexPluginInfo]->_hLib) + { + // To avoid the plugin change the data in SCNotification + // Each notification to pass to a plugin is a copy of SCNotification instance + SCNotification scNotif = *notification; + try + { + _pluginInfos[indexPluginInfo]->_pBeNotified(&scNotif); + } + catch (std::exception& e) + { + ::MessageBoxA(NULL, e.what(), "Exception", MB_OK); + } + catch (...) + { + TCHAR funcInfo[256]; + generic_sprintf(funcInfo, TEXT("notify(SCNotification *notification) : \r notification->nmhdr.code == %d\r notification->nmhdr.hwndFrom == %p\r notification->nmhdr.idFrom == %" PRIuPTR), \ + scNotif.nmhdr.code, scNotif.nmhdr.hwndFrom, scNotif.nmhdr.idFrom); + pluginCrashAlert(_pluginInfos[indexPluginInfo]->_moduleName.c_str(), funcInfo); + } + } +} + +// broadcast the notification to all plugins void PluginsManager::notify(const SCNotification *notification) { if (_noMoreNotification) // this boolean should be enabled after NPPN_SHUTDOWN has been sent @@ -614,27 +643,7 @@ void PluginsManager::notify(const SCNotification *notification) for (size_t i = 0, len = _pluginInfos.size() ; i < len ; ++i) { - if (_pluginInfos[i]->_hLib) - { - // To avoid the plugin change the data in SCNotification - // Each notification to pass to a plugin is a copy of SCNotification instance - SCNotification scNotif = *notification; - try - { - _pluginInfos[i]->_pBeNotified(&scNotif); - } - catch (std::exception& e) - { - ::MessageBoxA(NULL, e.what(), "Exception", MB_OK); - } - catch (...) - { - TCHAR funcInfo[256]; - generic_sprintf(funcInfo, TEXT("notify(SCNotification *notification) : \r notification->nmhdr.code == %d\r notification->nmhdr.hwndFrom == %p\r notification->nmhdr.idFrom == %" PRIuPTR),\ - scNotif.nmhdr.code, scNotif.nmhdr.hwndFrom, scNotif.nmhdr.idFrom); - pluginCrashAlert(_pluginInfos[i]->_moduleName.c_str(), funcInfo); - } - } + notify(i, notification); } } diff --git a/PowerEditor/src/MISC/PluginsManager/PluginsManager.h b/PowerEditor/src/MISC/PluginsManager/PluginsManager.h index a026bdba9..f47c5e75e 100644 --- a/PowerEditor/src/MISC/PluginsManager/PluginsManager.h +++ b/PowerEditor/src/MISC/PluginsManager/PluginsManager.h @@ -113,7 +113,8 @@ public: bool getShortcutByCmdID(int cmdID, ShortcutKey *sk); bool removeShortcutByCmdID(int cmdID); - void notify(const SCNotification *notification); + void notify(size_t indexPluginInfo, const SCNotification *notification); // to a plugin + void notify(const SCNotification *notification); // broadcast void relayNppMessages(UINT Message, WPARAM wParam, LPARAM lParam); bool relayPluginMessages(UINT Message, WPARAM wParam, LPARAM lParam); diff --git a/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp b/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp index cd7e96a3a..b9a4695d7 100644 --- a/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp +++ b/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp @@ -552,6 +552,13 @@ DWORD WINAPI PluginsAdminDlg::launchPluginInstallerThread(void* params) int index = lwp->_pPluginsManager->loadPlugin(installedPluginPath.c_str(), dll2Remove); lwp->_pPluginsManager->addInMenuFromPMIndex(index); + // Notify plugin that Notepad++ is ready + SCNotification scnN; + scnN.nmhdr.code = NPPN_READY; + scnN.nmhdr.hwndFrom = lwp->_hwnd; + scnN.nmhdr.idFrom = 0; + lwp->_pPluginsManager->notify(index, &scnN); + // End of Critical section ReleaseMutex(lwp->_mutex); } @@ -609,6 +616,7 @@ bool PluginsAdminDlg::installPlugins() lwp->_updaterDir = _updaterDir; lwp->_updaterFullPath = _updaterFullPath; lwp->_updaterParams = updaterParams; + lwp->_hwnd = _hSelf; lwp->_mutex = mutex; _lwps.push_back(lwp); diff --git a/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.h b/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.h index 658012067..f050fa7ae 100644 --- a/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.h +++ b/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.h @@ -168,6 +168,7 @@ struct LaunchWingupParams PluginsManager *_pPluginsManager; + HWND _hwnd = nullptr; HANDLE _mutex; };