summaryrefslogtreecommitdiff
path: root/src/mir_app
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-02-26 21:32:39 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-02-26 21:32:39 +0300
commitd90f32876f6b04e983c45bf41c3716c0a25134b9 (patch)
treeb1adcd89dfdefe5778a1d07033849ef74aeab66f /src/mir_app
parentf57ac413fffff5327e976cf5aaee8e307fbadcf5 (diff)
fixes #1593 (crash in clist_modern when a temporary contact gets deleted)
Diffstat (limited to 'src/mir_app')
-rw-r--r--src/mir_app/src/clcitems.cpp46
1 files changed, 25 insertions, 21 deletions
diff --git a/src/mir_app/src/clcitems.cpp b/src/mir_app/src/clcitems.cpp
index ff4ca6f96c..a50bc7170e 100644
--- a/src/mir_app/src/clcitems.cpp
+++ b/src/mir_app/src/clcitems.cpp
@@ -302,35 +302,39 @@ MIR_APP_DLL(void) Clist_DeleteItemFromTree(HWND hwnd, MCONTACT hItem)
ClcData *dat = (ClcData*)GetWindowLongPtr(hwnd, 0);
dat->bNeedsResort = true;
+ // if a contact is found in our contact list, remove it from its group and detach from cache
ClcGroup *group;
ClcContact *contact;
- if (!Clist_FindItem(hwnd, dat, hItem, &contact, &group)) {
- if (!IsHContactContact(hItem))
- return;
+ if (Clist_FindItem(hwnd, dat, hItem, &contact, &group)) {
+ Clist_RemoveItemFromGroup(hwnd, group, contact, 1);
+ contact->pce = nullptr;
+ }
+
+ // if we don't have this contact, simply try to update the number of contacts in a group
+ if (!IsHContactContact(hItem))
+ return;
- ptrW wszGroup(db_get_wsa(hItem, "CList", "Group"));
- if (wszGroup == nullptr)
- return;
+ ptrW wszGroup(db_get_wsa(hItem, "CList", "Group"));
+ if (wszGroup == nullptr)
+ return;
- // decrease member counts of all parent groups too
- group = &dat->list;
- int nameOffset = 0;
- for (int i = 0;; i++) {
- if (group->scanIndex == group->cl.getCount())
- break;
+ // decrease member counts of all parent groups too
+ group = &dat->list;
+ int nameOffset = 0;
+ for (int i = 0;; i++) {
+ if (group->scanIndex == group->cl.getCount())
+ break;
- ClcContact *cc = group->cl[i];
- if (cc->type == CLCIT_GROUP) {
- size_t len = mir_wstrlen(cc->szText);
- if (!wcsncmp(cc->szText, wszGroup.get() + nameOffset, len) && (wszGroup[nameOffset + len] == '\\' || wszGroup[nameOffset + len] == '\0')) {
- group->totalMembers--;
- if (wszGroup[nameOffset + len] == '\0')
- break;
- }
+ ClcContact *cc = group->cl[i];
+ if (cc->type == CLCIT_GROUP) {
+ size_t len = mir_wstrlen(cc->szText);
+ if (!wcsncmp(cc->szText, wszGroup.get() + nameOffset, len) && (wszGroup[nameOffset + len] == '\\' || wszGroup[nameOffset + len] == '\0')) {
+ group->totalMembers--;
+ if (wszGroup[nameOffset + len] == '\0')
+ break;
}
}
}
- else Clist_RemoveItemFromGroup(hwnd, group, contact, 1);
}
int fnGetContactHiddenStatus(MCONTACT hContact, char*, ClcData*)