1
0
Fork 0

Warn the user about duplicate plugins

This commit is contained in:
ζeh Matt 2023-09-21 11:49:47 +03:00
parent ef925bcfa7
commit ce73e9cdf7
No known key found for this signature in database
GPG Key ID: 18CE582C71A225B0
1 changed files with 14 additions and 1 deletions

View File

@ -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<std::wstring> 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());