summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mir_app/src/modules.cpp4
-rw-r--r--src/mir_app/src/newplugins.cpp25
-rw-r--r--src/mir_app/src/plugins.h2
3 files changed, 22 insertions, 9 deletions
diff --git a/src/mir_app/src/modules.cpp b/src/mir_app/src/modules.cpp
index 2c51f52b04..9f77361280 100644
--- a/src/mir_app/src/modules.cpp
+++ b/src/mir_app/src/modules.cpp
@@ -146,6 +146,10 @@ int LoadDefaultModules(void)
default: // smth went wrong, terminating
return 1;
}
+
+ for (auto &it : pluginList.rev_iter())
+ if (!it->bIsLast && it->bOk)
+ Plugin_UnloadDyn(it, false);
plugin_service = nullptr;
}
diff --git a/src/mir_app/src/newplugins.cpp b/src/mir_app/src/newplugins.cpp
index 21e8c78419..80bc8897c0 100644
--- a/src/mir_app/src/newplugins.cpp
+++ b/src/mir_app/src/newplugins.cpp
@@ -342,7 +342,7 @@ void Plugin_Uninit(pluginEntry *p)
pluginList.remove(p);
}
-int Plugin_UnloadDyn(pluginEntry *p)
+int Plugin_UnloadDyn(pluginEntry *p, bool bFreeDll)
{
if (p->bpi.hInst) {
if (CallPluginEventHook(p->bpi.hInst, hOkToExitEvent, 0, 0) != 0)
@@ -374,13 +374,19 @@ int Plugin_UnloadDyn(pluginEntry *p)
NotifyFastHook(hevUnloadModule, (WPARAM)p->bpi.pluginInfo, (LPARAM)p->bpi.hInst);
- Plugin_Uninit(p);
+ if (bFreeDll) {
+ Plugin_Uninit(p);
- // mark default plugins to be loaded
- if (!p->bIsCore)
- for (auto &it : pluginDefault)
- if (it.pImpl == p)
- it.pImpl = nullptr;
+ // mark default plugins to be loaded
+ if (!p->bIsCore)
+ for (auto &it : pluginDefault)
+ if (it.pImpl == p)
+ it.pImpl = nullptr;
+ }
+ else if (p->bLoaded) {
+ p->bpi.Unload();
+ p->bLoaded = false;
+ }
return TRUE;
}
@@ -445,7 +451,7 @@ pluginEntry* OpenPlugin(wchar_t *tszFileName, wchar_t *dir, wchar_t *path)
BASIC_PLUGIN_INFO bpi;
if (checkAPI(tszFullPath, &bpi, mirandaVersion, CHECKAPI_NONE)) {
// plugin is valid
- p->bHasBasicApi = true;
+ p->bHasBasicApi = p->bIsLast = true;
if (bIsDb)
p->bIsDatabase = true;
else
@@ -694,6 +700,7 @@ int LaunchServicePlugin(pluginEntry *p)
{
// plugin load failed - terminating Miranda
if (!p->bLoaded) {
+ RegisterModule(p->bpi.hInst);
if (p->bpi.Load() != ERROR_SUCCESS) {
Plugin_Uninit(p);
return SERVICE_FAILED;
@@ -856,6 +863,8 @@ int LoadNewPluginsModuleInfos(void)
hPluginListHeap = HeapCreate(HEAP_NO_SERIALIZE, 0, 0);
mirandaVersion = Miranda_GetVersion();
+ RegisterModule(g_hInst);
+
// remember where the mirandaboot.ini goes
PathToAbsoluteW(L"mirandaboot.ini", mirandabootini);
diff --git a/src/mir_app/src/plugins.h b/src/mir_app/src/plugins.h
index d860df1a67..9be88a225f 100644
--- a/src/mir_app/src/plugins.h
+++ b/src/mir_app/src/plugins.h
@@ -74,7 +74,7 @@ pluginEntry* OpenPlugin(wchar_t *tszFileName, wchar_t *dir, wchar_t *path);
bool TryLoadPlugin(pluginEntry *p, bool bDynamic);
void Plugin_Uninit(pluginEntry *p);
-int Plugin_UnloadDyn(pluginEntry *p);
+int Plugin_UnloadDyn(pluginEntry *p, bool bFreeDll = true);
typedef BOOL (*SCAN_PLUGINS_CALLBACK) (WIN32_FIND_DATA * fd, wchar_t *path, WPARAM wParam, LPARAM lParam);
void enumPlugins(SCAN_PLUGINS_CALLBACK cb, WPARAM wParam, LPARAM lParam);