diff --git a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp index d42a5ae8..f74e7cbe 100644 --- a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp +++ b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp @@ -47,6 +47,10 @@ bool PluginsManager::unloadPlugin(int index, HWND nppHandle) int PluginsManager::loadPlugin(const TCHAR *pluginFilePath, vector & dll2Remove) { + const TCHAR *pluginFileName = ::PathFindFileName(pluginFilePath); + if (isInLoadedDlls(pluginFileName)) + return 0; + PluginInfo *pi = new PluginInfo; try { pi->_moduleName = PathFindFileName(pluginFilePath); @@ -181,7 +185,7 @@ int PluginsManager::loadPlugin(const TCHAR *pluginFilePath, vector dllNames; vector dll2Remove; - generic_string nppPath = (NppParameters::getInstance())->getNppPath(); - + NppParameters * nppParams = NppParameters::getInstance(); + generic_string nppPath = nppParams->getNppPath(); generic_string pluginsFullPathFilter = (dir && dir[0])?dir:nppPath; pluginsFullPathFilter += TEXT("\\plugins\\*.dll"); @@ -232,8 +236,6 @@ bool PluginsManager::loadPlugins(const TCHAR *dir) plugins1stFullPath += foundData.cFileName; dllNames.push_back(plugins1stFullPath); - NppParameters * nppParams = NppParameters::getInstance(); - while (::FindNextFile(hFindFile, &foundData)) { bool isInBlackList = nppParams->isInBlackList(foundData.cFileName); diff --git a/PowerEditor/src/MISC/PluginsManager/PluginsManager.h b/PowerEditor/src/MISC/PluginsManager/PluginsManager.h index 8273e19c..d6b795a7 100644 --- a/PowerEditor/src/MISC/PluginsManager/PluginsManager.h +++ b/PowerEditor/src/MISC/PluginsManager/PluginsManager.h @@ -120,6 +120,7 @@ private: vector _pluginInfos; vector _pluginsCommands; + vector _loadedDlls; bool _isDisabled; IDAllocator _dynamicIDAlloc; IDAllocator _markerAlloc; @@ -129,6 +130,16 @@ private: msg += funcSignature; ::MessageBox(NULL, msg.c_str(), TEXT(" just crash in\r"), MB_OK|MB_ICONSTOP); }; + bool isInLoadedDlls(const TCHAR *fn) const { + for (size_t i = 0; i < _loadedDlls.size(); i++) + if (generic_stricmp(fn, _loadedDlls[i].c_str()) == 0) + return true; + return false; + }; + + void addInLoadedDlls(const TCHAR *fn) { + _loadedDlls.push_back(fn); + }; }; #define EXT_LEXER_DECL __stdcall diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index e3936cc8..6a9f3fe1 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -341,11 +341,19 @@ LRESULT Notepad_plus::init(HWND hwnd) _scintillaCtrls4Plugins.init(_pPublicInterface->getHinst(), hwnd); _pluginsManager.init(nppData); - _pluginsManager.loadPlugins(); + + // Load plugins firstly from "%APPDATA%/Notepad++/plugins" + // if Notepad++ is not in localConf mode. + // All the dll loaded are marked. const TCHAR *appDataNpp = pNppParam->getAppDataNppDir(); if (appDataNpp[0]) _pluginsManager.loadPlugins(appDataNpp); + // Load plugins from its installation directory. + // All loaded dll will be ignored + _pluginsManager.loadPlugins(); + + _restoreButton.init(_pPublicInterface->getHinst(), hwnd); diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 0449e377..837a3323 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -771,11 +771,11 @@ bool NppParameters::load() PathAppend(localConfPath, localConfFile); // Test if localConf.xml exist - bool isLocal = (PathFileExists(localConfPath.c_str()) == TRUE); + _isLocal = (PathFileExists(localConfPath.c_str()) == TRUE); // Under vista and windows 7, the usage of doLocalConf.xml is not allowed // if Notepad++ is installed in "program files" directory, because of UAC - if (isLocal) + if (_isLocal) { // We check if OS is Vista or above if (_winVersion >= WV_VISTA) @@ -789,11 +789,11 @@ bool NppParameters::load() ::PathRemoveFileSpec(nppDirLocation); if (lstrcmp(progPath, nppDirLocation) == 0) - isLocal = false; + _isLocal = false; } } - if (isLocal) + if (_isLocal) { _userPath = _nppPath; } diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index 9e12367f..5d4eda69 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -1422,6 +1422,10 @@ public: _pNativeLangSpeaker = nls; }; + bool isLocal() const { + return _isLocal; + }; + private: NppParameters(); ~NppParameters(); @@ -1478,6 +1482,7 @@ private: WNDPROC _transparentFuncAddr; WNDPROC _enableThemeDialogTextureFuncAddr; + bool _isLocal; vector _shortcuts; //main menu shortuts. Static size