summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2023-02-10 12:54:20 +0300
committerGeorge Hazan <ghazan@miranda.im>2023-02-10 12:54:20 +0300
commitef0ba268b340eaf1217a96d763342c25668588b4 (patch)
tree17396375e213043c2ce1c59b50b7f30488dcb83d /src
parent33733576589076f080ddfa000b899843016a2597 (diff)
Protocols: preventing recursive contact deletion
Diffstat (limited to 'src')
-rw-r--r--src/core/stdmsg/src/msgs.cpp4
-rw-r--r--src/mir_app/src/proto_accs.cpp8
-rw-r--r--src/mir_core/src/db.cpp6
3 files changed, 7 insertions, 11 deletions
diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp
index 9f5be7be28..066875a243 100644
--- a/src/core/stdmsg/src/msgs.cpp
+++ b/src/core/stdmsg/src/msgs.cpp
@@ -224,9 +224,9 @@ static int MessageSettingChanged(WPARAM hContact, LPARAM lParam)
}
// If a contact gets deleted, close its message window if there is any
-static int ContactDeleted(WPARAM wParam, LPARAM)
+static int ContactDeleted(WPARAM hContact, LPARAM)
{
- auto *pDlg = Srmm_FindDialog(wParam);
+ auto *pDlg = Srmm_FindDialog(hContact);
if (pDlg)
pDlg->CloseTab();
diff --git a/src/mir_app/src/proto_accs.cpp b/src/mir_app/src/proto_accs.cpp
index 501497361c..690c58bb76 100644
--- a/src/mir_app/src/proto_accs.cpp
+++ b/src/mir_app/src/proto_accs.cpp
@@ -150,13 +150,6 @@ void WriteDbAccounts()
/////////////////////////////////////////////////////////////////////////////////////////
-static int OnContactDeleted(WPARAM hContact, LPARAM)
-{
- if (auto *ppro = Proto_GetInstance(hContact))
- ppro->OnContactDeleted(hContact);
- return 0;
-}
-
static int OnEventEdited(WPARAM hContact, LPARAM hDbEvent)
{
if (auto *ppro = Proto_GetInstance(hContact))
@@ -225,7 +218,6 @@ int LoadAccountsModule(void)
}
hHooks[1] = HookEvent(ME_SYSTEM_PRESHUTDOWN, UninitializeStaticAccounts);
- hHooks[2] = HookEvent(ME_DB_CONTACT_DELETED, OnContactDeleted);
hHooks[3] = HookEvent(ME_DB_EVENT_EDITED, OnEventEdited);
return 0;
}
diff --git a/src/mir_core/src/db.cpp b/src/mir_core/src/db.cpp
index 5b2048c2bb..23584d2fb1 100644
--- a/src/mir_core/src/db.cpp
+++ b/src/mir_core/src/db.cpp
@@ -98,7 +98,7 @@ MIR_CORE_DLL(MCONTACT) db_add_contact(void)
return hNew;
}
-MIR_CORE_DLL(int) db_delete_contact(MCONTACT hContact)
+MIR_CORE_DLL(int) db_delete_contact(MCONTACT hContact, bool bFromProto)
{
ptrW wszPhoto(db_get_wsa(hContact, "ContactPhoto", "File"));
if (wszPhoto != nullptr) {
@@ -109,6 +109,10 @@ MIR_CORE_DLL(int) db_delete_contact(MCONTACT hContact)
#endif
}
+ if (!bFromProto)
+ if (auto *ppro = Proto_GetInstance(hContact))
+ ppro->OnContactDeleted(hContact);
+
Netlib_Logf(nullptr, "Contact deleted: %d", hContact);
return (g_pCurrDb) ? g_pCurrDb->DeleteContact(hContact) : 0;
}