diff options
author | George Hazan <ghazan@miranda.im> | 2018-03-28 15:41:21 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-03-28 15:41:21 +0300 |
commit | c2bb7727483b9b5620e8cc0ce6adae35ee78d0a4 (patch) | |
tree | ba8e0d4e687fcbdc324230ec24b5ea81cf4d9690 /src/mir_app | |
parent | 9e211fa67e180affc7ddc66efd9af85c55b99e73 (diff) |
fix for proper initialization of partially loaded plugins
Diffstat (limited to 'src/mir_app')
-rw-r--r-- | src/mir_app/src/newplugins.cpp | 65 |
1 files changed, 30 insertions, 35 deletions
diff --git a/src/mir_app/src/newplugins.cpp b/src/mir_app/src/newplugins.cpp index 3978b14dd8..1710e71a3d 100644 --- a/src/mir_app/src/newplugins.cpp +++ b/src/mir_app/src/newplugins.cpp @@ -523,47 +523,42 @@ int isPluginOnWhiteList(const wchar_t* pluginname) bool TryLoadPlugin(pluginEntry *p, bool bDynamic)
{
- // 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->bpi.hInst == nullptr) {
+ if (!bDynamic && !isPluginOnWhiteList(p->pluginname))
+ return false;
- if (!bDynamic && !isPluginOnWhiteList(p->pluginname))
- 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;
- 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;
+ 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;
+ }
- 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;
+ p->bpi = bpi;
+ p->bOk = p->bHasBasicApi = true;
}
- 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;
+ 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);
}
-
- // we're loading new implementation dynamically, let the old one die
- if (!p->bIsCore)
- Plugin_UnloadDyn(pluginDefault[idx].pImpl);
}
}
}
|