summaryrefslogtreecommitdiff
path: root/src/mir_app
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-08-27 19:31:44 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-08-27 19:31:44 +0300
commit12540b96cb64e6fa84d0c7fd2b64864b13a73132 (patch)
tree59a66753941a6d9d0fed88ffa1146ffc4be12021 /src/mir_app
parent8579501c5918a05b0f4a8fc0510eeee429c27d36 (diff)
fixes #1547 (Miranda crashes on import from mmap profile when VK plugin is disabled)
Diffstat (limited to 'src/mir_app')
-rw-r--r--src/mir_app/src/CMPluginBase.cpp4
-rw-r--r--src/mir_app/src/miranda.h16
-rw-r--r--src/mir_app/src/newplugins.cpp2
-rw-r--r--src/mir_app/src/proto_accs.cpp2
-rw-r--r--src/mir_app/src/proto_utils.cpp2
-rw-r--r--src/mir_app/src/protocols.cpp11
6 files changed, 25 insertions, 12 deletions
diff --git a/src/mir_app/src/CMPluginBase.cpp b/src/mir_app/src/CMPluginBase.cpp
index 4d8a27f48c..2875c00fe1 100644
--- a/src/mir_app/src/CMPluginBase.cpp
+++ b/src/mir_app/src/CMPluginBase.cpp
@@ -290,9 +290,7 @@ void CMPluginBase::SetUniqueId(const char *pszUniqueId)
if (pszUniqueId == nullptr)
return;
- MBaseProto tmp;
- tmp.szName = (char*)m_szModuleName;
- MBaseProto *pd = g_arProtos.find(&tmp);
+ MBaseProto *pd = g_arProtos.find((MBaseProto*)&m_szModuleName);
if (pd != nullptr)
pd->szUniqueId = mir_strdup(pszUniqueId);
}
diff --git a/src/mir_app/src/miranda.h b/src/mir_app/src/miranda.h
index 23eac6d4ea..bb906d0e35 100644
--- a/src/mir_app/src/miranda.h
+++ b/src/mir_app/src/miranda.h
@@ -141,8 +141,19 @@ extern MStatus g_statuses[MAX_STATUS_COUNT];
extern LIST<PROTOACCOUNT> accounts;
-struct MBaseProto : public PROTOCOLDESCRIPTOR
+struct MBaseProto : public PROTOCOLDESCRIPTOR, public MZeroedObject
{
+ MBaseProto(const char *_proto)
+ {
+ this->szName = mir_strdup(_proto);
+ }
+
+ ~MBaseProto()
+ {
+ mir_free(szName);
+ mir_free(szUniqueId);
+ }
+
pfnInitProto fnInit;
pfnUninitProto fnUninit;
@@ -150,7 +161,8 @@ struct MBaseProto : public PROTOCOLDESCRIPTOR
char *szUniqueId; // name of the unique setting that identifies a contact
};
-extern LIST<MBaseProto> g_arProtos, g_arFilters;
+extern OBJLIST<MBaseProto> g_arProtos;
+extern LIST<MBaseProto> g_arFilters;
INT_PTR ProtoCallService(const char *szModule, const char *szService, WPARAM wParam, LPARAM lParam);
diff --git a/src/mir_app/src/newplugins.cpp b/src/mir_app/src/newplugins.cpp
index d29a8914e4..ddd630f69a 100644
--- a/src/mir_app/src/newplugins.cpp
+++ b/src/mir_app/src/newplugins.cpp
@@ -240,6 +240,8 @@ void Plugin_Uninit(pluginEntry *p)
HINSTANCE hInst = p->m_pPlugin->getInst();
// we need to kill all resources which belong to that DLL before calling FreeLibrary
+ KillModuleAccounts(hInst);
+ KillModuleSubclassing(hInst);
KillModuleEventHooks(hInst);
KillModuleServices(hInst);
diff --git a/src/mir_app/src/proto_accs.cpp b/src/mir_app/src/proto_accs.cpp
index 55cbcd8270..8d7f068c9e 100644
--- a/src/mir_app/src/proto_accs.cpp
+++ b/src/mir_app/src/proto_accs.cpp
@@ -401,6 +401,8 @@ void KillModuleAccounts(HINSTANCE hInst)
DeactivateAccount(pa, DAF_DYNAMIC);
}
}
+
+ g_arProtos.remove(g_arProtos.indexOf(&pd));
}
}
diff --git a/src/mir_app/src/proto_utils.cpp b/src/mir_app/src/proto_utils.cpp
index 4bd1b3da0e..7cbff3bb47 100644
--- a/src/mir_app/src/proto_utils.cpp
+++ b/src/mir_app/src/proto_utils.cpp
@@ -28,7 +28,7 @@ static int CompareProtos(const MBaseProto *p1, const MBaseProto *p2)
return strcmp(p1->szName, p2->szName);
}
-LIST<MBaseProto> g_arProtos(10, CompareProtos);
+OBJLIST<MBaseProto> g_arProtos(10, CompareProtos);
extern HANDLE hAckEvent;
diff --git a/src/mir_app/src/protocols.cpp b/src/mir_app/src/protocols.cpp
index f4aea76896..6b6aea19e8 100644
--- a/src/mir_app/src/protocols.cpp
+++ b/src/mir_app/src/protocols.cpp
@@ -106,8 +106,7 @@ MIR_APP_DLL(PROTOCOLDESCRIPTOR*) Proto_RegisterModule(int type, const char *szNa
bool bTryActivate = false;
MBaseProto *pd = Proto_GetProto(szName);
if (pd == nullptr) {
- pd = (MBaseProto*)mir_calloc(sizeof(MBaseProto));
- pd->szName = mir_strdup(szName);
+ pd = new MBaseProto(szName);
g_arProtos.insert(pd);
}
else bTryActivate = true;
@@ -158,17 +157,17 @@ MIR_APP_DLL(const char*) Proto_GetUniqueId(const char *szModuleName)
if (szModuleName == nullptr)
return nullptr;
- MBaseProto tmp;
+ const char *szProto;
PROTOACCOUNT *pa = Proto_GetAccount(szModuleName);
if (pa != nullptr) {
if (pa->szUniqueId != nullptr)
return pa->szUniqueId;
- tmp.szName = pa->szProtoName;
+ szProto = pa->szProtoName;
}
- else tmp.szName = (char*)szModuleName;
+ else szProto = szModuleName;
- MBaseProto *pd = g_arProtos.find(&tmp);
+ MBaseProto *pd = g_arProtos.find((MBaseProto*)&szProto);
return (pd != nullptr) ? pd->szUniqueId : nullptr;
}