diff options
author | George Hazan <ghazan@miranda.im> | 2018-03-28 00:02:18 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-03-28 00:02:18 +0300 |
commit | bea9ca96330b7391df275dcaa0597623458a54f3 (patch) | |
tree | ce660cb469fce518a45c82703ed290f9a2dd0ba8 | |
parent | 3ed57b9844b340d1732d85d76f2184498aba5609 (diff) |
fix for plugin loader: it shall not unload already loaded plugins
-rw-r--r-- | src/mir_app/src/newplugins.cpp | 72 |
1 files changed, 38 insertions, 34 deletions
diff --git a/src/mir_app/src/newplugins.cpp b/src/mir_app/src/newplugins.cpp index 80bc8897c0..fe84b8e321 100644 --- a/src/mir_app/src/newplugins.cpp +++ b/src/mir_app/src/newplugins.cpp @@ -523,45 +523,52 @@ int isPluginOnWhiteList(const wchar_t* pluginname) bool TryLoadPlugin(pluginEntry *p, bool bDynamic)
{
- wchar_t exe[MAX_PATH], tszFullPath[MAX_PATH];
- GetModuleFileName(nullptr, exe, _countof(exe));
- wchar_t* slice = wcsrchr(exe, '\\');
- if (slice)
- *slice = 0;
+ // if plugin is already loaded, don't ask questions, just mark it as loaded
+ if (p->bpi.hInst != nullptr) {
+ RegisterModule(p->bpi.hInst);
+ p->bLoaded = true;
+ return true;
+ }
- if (!p->bLoaded && !p->bIsDatabase && !p->bIsClist) {
- if (!bDynamic && !isPluginOnWhiteList(p->pluginname))
- return false;
+ if (!bDynamic && !isPluginOnWhiteList(p->pluginname))
+ return false;
- if (!p->bHasBasicApi) {
- BASIC_PLUGIN_INFO bpi;
- mir_snwprintf(tszFullPath, L"%s\\%s\\%s", exe, (p->bIsCore) ? L"Core" : L"Plugins", p->pluginname);
- if (!checkAPI(tszFullPath, &bpi, mirandaVersion, CHECKAPI_NONE)) {
- p->bFailed = true;
- return false;
- }
+ if (!p->bHasBasicApi) {
+ wchar_t exe[MAX_PATH], tszFullPath[MAX_PATH];
+ GetModuleFileName(nullptr, exe, _countof(exe));
+ wchar_t* slice = wcsrchr(exe, '\\');
+ if (slice)
+ *slice = 0;
- p->bpi = bpi;
- p->bOk = p->bHasBasicApi = true;
+ BASIC_PLUGIN_INFO bpi;
+ mir_snwprintf(tszFullPath, L"%s\\%s\\%s", exe, (p->bIsCore) ? L"Core" : L"Plugins", p->pluginname);
+ if (!checkAPI(tszFullPath, &bpi, mirandaVersion, CHECKAPI_NONE)) {
+ p->bFailed = true;
+ return false;
}
- if (p->bpi.Interfaces) {
- MUUID *piface = p->bpi.Interfaces;
- for (int i = 0; piface[i] != miid_last; i++) {
- int idx = getDefaultPluginIdx(piface[i]);
- if (idx != -1 && pluginDefault[idx].pImpl) {
- if (!bDynamic) { // this place is already occupied, skip & disable
- SetPluginOnWhiteList(p->pluginname, 0);
- return false;
- }
-
- // we're loading new implementation dynamically, let the old one die
- if (!p->bIsCore)
- Plugin_UnloadDyn(pluginDefault[idx].pImpl);
+ p->bpi = bpi;
+ p->bOk = p->bHasBasicApi = true;
+ }
+
+ if (p->bpi.Interfaces) {
+ MUUID *piface = p->bpi.Interfaces;
+ for (int i = 0; piface[i] != miid_last; i++) {
+ int idx = getDefaultPluginIdx(piface[i]);
+ if (idx != -1 && pluginDefault[idx].pImpl) {
+ if (!bDynamic) { // this place is already occupied, skip & disable
+ SetPluginOnWhiteList(p->pluginname, 0);
+ return false;
}
+
+ // we're loading new implementation dynamically, let the old one die
+ if (!p->bIsCore)
+ Plugin_UnloadDyn(pluginDefault[idx].pImpl);
}
}
+ }
+ if (!p->bLoaded) {
RegisterModule(p->bpi.hInst);
if (p->bpi.Load() != 0)
return false;
@@ -576,10 +583,7 @@ bool TryLoadPlugin(pluginEntry *p, bool bDynamic) }
}
}
- else if (p->bpi.hInst != nullptr) {
- RegisterModule(p->bpi.hInst);
- p->bLoaded = true;
- }
+
return true;
}
|