From ce73e9cdf74135caccda811a38b4bc2d04c45874 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Thu, 21 Sep 2023 11:49:47 +0300 Subject: [PATCH] Warn the user about duplicate plugins --- src/dbg/plugin_loader.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/dbg/plugin_loader.cpp b/src/dbg/plugin_loader.cpp index f4bb27f0..6c59c6c8 100644 --- a/src/dbg/plugin_loader.cpp +++ b/src/dbg/plugin_loader.cpp @@ -143,9 +143,9 @@ bool pluginload(const char* pluginName, bool loadall) { if(_stricmp(it->plugname, name.c_str()) == 0) { - dprintf(QT_TRANSLATE_NOOP("DBG", "[PLUGIN] %s already loaded\n"), it->plugname); if(!loadall) { + dprintf(QT_TRANSLATE_NOOP("DBG", "[PLUGIN] %s already loaded\n"), it->plugname); SetCurrentDirectoryW(currentDir); } return false; @@ -456,6 +456,10 @@ static std::vector enumerateAvailablePlugins(const std::wstring & while(FindNextFileW(hSearch, &foundData)); FindClose(hSearch); + + // Sort the list of plugins. + std::sort(result.begin(), result.end()); + return result; } @@ -481,6 +485,15 @@ void pluginloadall(const char* pluginDir) // Enumerate all plugins from plugins directory. const auto availablePlugins = enumerateAvailablePlugins(StringUtils::Utf8ToUtf16(pluginDir)); + // Check the sorted list for duplicate names. + for(size_t i = 1; i < availablePlugins.size(); ++i) + { + if(availablePlugins[i] == availablePlugins[i - 1]) + { + dprintf(QT_TRANSLATE_NOOP("DBG", "[PLUGIN] Plugin with same name found: %s, will only load plugin using sub-directory.\n"), StringUtils::Utf16ToUtf8(availablePlugins[i]).c_str()); + } + } + GetCurrentDirectoryW(deflen, currentDir); SetCurrentDirectoryW(pluginDirectory.c_str());