@@ -92,19 +92,24 @@ static std::string pluginGetFullPath(std::string pluginName)
92
92
{
93
93
std::string pluginPath = StringUtils::Utf16ToUtf8 (pluginDirectory) + " \\ " + pluginName;
94
94
95
- // Check if the plugin is a directory.
96
- if (PathIsDirectoryW (StringUtils::Utf8ToUtf16 (pluginPath).c_str ()))
95
+ // Check if the plugin is in a sub-directory.
96
+ std::string pluginPathSubdir = pluginPath + " \\ " + pluginName + pluginExtension;
97
+ if (PathIsDirectoryW (StringUtils::Utf8ToUtf16 (pluginPathSubdir).c_str ()))
97
98
{
98
- // Plugin is probably inside the directory.
99
- pluginPath += " \\ " + pluginName + pluginExtension ;
99
+ // Plugin resides in sub directory.
100
+ return pluginPathSubdir ;
100
101
}
101
- else
102
+
103
+ // Check if plugin is from the main plugin directory.
104
+ std::string pluginPathWithExt = pluginPath + pluginExtension;
105
+ if (PathFileExistsW (StringUtils::Utf8ToUtf16 (pluginPathWithExt).c_str ()))
102
106
{
103
- // Ordinary file
104
- pluginPath += pluginExtension ;
107
+ // Plugin resides in main plugins directory.
108
+ return pluginPathWithExt ;
105
109
}
106
110
107
- return pluginPath;
111
+ // Unable to determine the full path to the plugin, probably doesn't exist.
112
+ return " " ;
108
113
}
109
114
110
115
/* *
@@ -133,17 +138,17 @@ bool pluginload(const char* pluginName, bool loadall)
133
138
}
134
139
135
140
// Check to see if this plugin is already loaded
136
- if (!loadall)
141
+ EXCLUSIVE_ACQUIRE (LockPluginList);
142
+ for (auto it = pluginList.begin (); it != pluginList.end (); ++it)
137
143
{
138
- EXCLUSIVE_ACQUIRE (LockPluginList);
139
- for (auto it = pluginList.begin (); it != pluginList.end (); ++it)
144
+ if (_stricmp (it->plugname , name.c_str ()) == 0 )
140
145
{
141
- if (_stricmp (it->plugname , name.c_str ()) == 0 )
146
+ dprintf (QT_TRANSLATE_NOOP (" DBG" , " [PLUGIN] %s already loaded\n " ), it->plugname );
147
+ if (!loadall)
142
148
{
143
- dprintf (QT_TRANSLATE_NOOP (" DBG" , " [PLUGIN] %s already loaded\n " ), it->plugname );
144
149
SetCurrentDirectoryW (currentDir);
145
- return false ;
146
150
}
151
+ return false ;
147
152
}
148
153
}
149
154
0 commit comments