From e19a213605f1974c2000a9f2b1b7d6d4666cdb90 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 25 Jun 2018 20:43:51 +0300 Subject: duplicate cache item removed to avoid rare crashes --- plugins/Clist_modern/src/modern_clc.cpp | 12 ++++++------ plugins/Clist_modern/src/modern_clc.h | 2 +- plugins/Clist_modern/src/modern_clcitems.cpp | 2 -- plugins/Clist_modern/src/modern_clcpaint.cpp | 8 ++++---- plugins/Clist_modern/src/modern_clcutils.cpp | 2 +- plugins/Clist_modern/src/modern_contact.cpp | 4 ++-- 6 files changed, 14 insertions(+), 16 deletions(-) (limited to 'plugins/Clist_modern/src') diff --git a/plugins/Clist_modern/src/modern_clc.cpp b/plugins/Clist_modern/src/modern_clc.cpp index bf60ce87c9..5aa6926c45 100644 --- a/plugins/Clist_modern/src/modern_clc.cpp +++ b/plugins/Clist_modern/src/modern_clc.cpp @@ -952,7 +952,7 @@ static LRESULT clcOnMouseMove(ClcData *dat, HWND hwnd, UINT, WPARAM wParam, LPAR cliGetRowByIndex(dat, dat->iDragItem, &contSour, nullptr); if (contSour->isChat()) break; - if (contSour->type == CLCIT_CONTACT && mir_strcmp(contSour->proto, META_PROTO)) { + if (contSour->type == CLCIT_CONTACT && mir_strcmp(contSour->pce->szProto, META_PROTO)) { if (!contSour->iSubNumber) hNewCursor = LoadCursor(g_hMirApp, MAKEINTRESOURCE(IDC_DROPUSER)); /// Add to meta else @@ -965,7 +965,7 @@ static LRESULT clcOnMouseMove(ClcData *dat, HWND hwnd, UINT, WPARAM wParam, LPAR cliGetRowByIndex(dat, dat->iDragItem, &contSour, nullptr); if (contSour->isChat() || contDest->isChat()) break; - if (contSour->type == CLCIT_CONTACT && mir_strcmp(contSour->proto, META_PROTO)) { + if (contSour->type == CLCIT_CONTACT && mir_strcmp(contSour->pce->szProto, META_PROTO)) { if (!contSour->iSubNumber) hNewCursor = LoadCursor(g_hMirApp, MAKEINTRESOURCE(IDC_DROPUSER)); /// Add to meta else if (contSour->subcontacts == contDest) @@ -980,7 +980,7 @@ static LRESULT clcOnMouseMove(ClcData *dat, HWND hwnd, UINT, WPARAM wParam, LPAR cliGetRowByIndex(dat, dat->iDragItem, &contSour, nullptr); if (contSour->isChat() || contDest->isChat()) break; - if (contSour->type == CLCIT_CONTACT && mir_strcmp(contSour->proto, META_PROTO)) { + if (contSour->type == CLCIT_CONTACT && mir_strcmp(contSour->pce->szProto, META_PROTO)) { if (!contSour->iSubNumber) hNewCursor = LoadCursor(g_hMirApp, MAKEINTRESOURCE(IDC_DROPUSER)); /// Add to meta else if (contDest->subcontacts == contSour->subcontacts) @@ -1084,7 +1084,7 @@ static LRESULT clcOnLButtonUp(ClcData *dat, HWND hwnd, UINT msg, WPARAM wParam, break; if (contSour->type == CLCIT_CONTACT) { MCONTACT hcontact = contSour->hContact; - if (mir_strcmp(contSour->proto, META_PROTO)) { + if (mir_strcmp(contSour->pce->szProto, META_PROTO)) { if (!contSour->iSubNumber) { MCONTACT hDest = contDest->hContact; mir_snwprintf(Wording, TranslateT("Do you want contact '%s' to be converted to metacontact and '%s' be added to it?"), contDest->szText, contSour->szText); @@ -1121,7 +1121,7 @@ static LRESULT clcOnLButtonUp(ClcData *dat, HWND hwnd, UINT msg, WPARAM wParam, if (contSour->isChat() || contDest->isChat()) break; if (contSour->type == CLCIT_CONTACT) { - if (!mir_strcmp(contSour->proto, META_PROTO)) + if (!mir_strcmp(contSour->pce->szProto, META_PROTO)) break; if (!contSour->iSubNumber) { MCONTACT hcontact = contSour->hContact; @@ -1163,7 +1163,7 @@ static LRESULT clcOnLButtonUp(ClcData *dat, HWND hwnd, UINT msg, WPARAM wParam, if (contSour->isChat() || contDest->isChat()) break; if (contSour->type == CLCIT_CONTACT) { - if (!mir_strcmp(contSour->proto, META_PROTO)) + if (!mir_strcmp(contSour->pce->szProto, META_PROTO)) break; if (!contSour->iSubNumber) { MCONTACT hcontact = contSour->hContact; diff --git a/plugins/Clist_modern/src/modern_clc.h b/plugins/Clist_modern/src/modern_clc.h index a4dff8a27d..aae64ead66 100644 --- a/plugins/Clist_modern/src/modern_clc.h +++ b/plugins/Clist_modern/src/modern_clc.h @@ -204,7 +204,7 @@ struct ClcContact : public ClcContactBase { return (style & CLS_CHECKBOXES && type == CLCIT_CONTACT) || (style & CLS_GROUPCHECKBOXES && type == CLCIT_GROUP) || (type == CLCIT_INFO && flags & CLCIIF_CHECKBOX); } __forceinline bool isChat() const - { return (type == CLCIT_CONTACT) && (db_get_b(hContact, proto, "ChatRoom", 0) != 0); + { return (type == CLCIT_CONTACT) && (db_get_b(hContact, pce->szProto, "ChatRoom", 0) != 0); } }; diff --git a/plugins/Clist_modern/src/modern_clcitems.cpp b/plugins/Clist_modern/src/modern_clcitems.cpp index d5c6efd7b0..593fe7fb9d 100644 --- a/plugins/Clist_modern/src/modern_clcitems.cpp +++ b/plugins/Clist_modern/src/modern_clcitems.cpp @@ -63,7 +63,6 @@ void AddSubcontacts(ClcData *dat, ClcContact *cont, BOOL showOfflineHereGroup) p.iImage = Clist_GetContactIcon(pdnce->hContact); memset(p.iExtraImage, 0xFF, sizeof(p.iExtraImage)); - p.proto = pdnce->szProto; p.type = CLCIT_CONTACT; p.flags = 0; p.iSubNumber = i + 1; @@ -129,7 +128,6 @@ static void _LoadDataToContact(ClcContact *cont, ClcCacheEntry *pdnce, ClcGroup cont->lastPaintCounter = 0; cont->bImageIsSpecial = false; cont->hContact = hContact; - cont->proto = szProto; if (szProto != nullptr && !Clist_IsHiddenMode(dat, pdnce->m_iStatus)) cont->flags |= CONTACTF_ONLINE; diff --git a/plugins/Clist_modern/src/modern_clcpaint.cpp b/plugins/Clist_modern/src/modern_clcpaint.cpp index 31fdb61c53..a62f2174a3 100644 --- a/plugins/Clist_modern/src/modern_clcpaint.cpp +++ b/plugins/Clist_modern/src/modern_clcpaint.cpp @@ -519,7 +519,7 @@ MODERNMASK* CLCPaint::_GetCLCContactRowBackModernMask(ClcGroup *group, ClcContac } else _AddParamShort(mpModernMask, hi_Type, hi_Contact); - AddParam(mpModernMask, HASH[hi_Protocol], Drawing->proto, 0); + AddParam(mpModernMask, HASH[hi_Protocol], Drawing->pce->szProto, 0); _AddParamShort(mpModernMask, hi_RootGroup, (group && group->parent == nullptr) ? hi_True : hi_False); switch (GetContactCachedStatus(Drawing->hContact)) { case ID_STATUS_ONLINE: _AddParamShort(mpModernMask, hi_Status, hi_ONLINE); break; @@ -1233,7 +1233,7 @@ void CLCPaint::_PaintRowItemsEx(HDC hdcMem, ClcData *dat, ClcContact *Drawing, R break; case SETTING_AVATAR_OVERLAY_TYPE_PROTOCOL: { - int item = g_clistApi.pfnIconFromStatusMode(Drawing->proto, Drawing->proto == nullptr ? ID_STATUS_OFFLINE : GetContactCachedStatus(Drawing->hContact), Drawing->hContact); + int item = g_clistApi.pfnIconFromStatusMode(Drawing->pce->szProto, Drawing->pce->szProto == nullptr ? ID_STATUS_OFFLINE : GetContactCachedStatus(Drawing->hContact), Drawing->hContact); if (item != -1) _DrawStatusIcon(Drawing, dat, item, hdcMem, p_rect.left, p_rect.top, ICON_HEIGHT, ICON_HEIGHT, @@ -2474,7 +2474,7 @@ void CLCPaint::_DrawContactAvatar(HDC hdcMem, ClcData *dat, ClcContact *Drawing, overlayIdx = g_pAvatarOverlayIcons[GetContactCachedStatus(Drawing->hContact) - ID_STATUS_OFFLINE].listID; break; case SETTING_AVATAR_OVERLAY_TYPE_PROTOCOL: - overlayIdx = g_clistApi.pfnIconFromStatusMode(Drawing->proto, Drawing->proto == nullptr ? ID_STATUS_OFFLINE : GetContactCachedStatus(Drawing->hContact), Drawing->hContact); + overlayIdx = g_clistApi.pfnIconFromStatusMode(Drawing->pce->szProto, Drawing->pce->szProto == nullptr ? ID_STATUS_OFFLINE : GetContactCachedStatus(Drawing->hContact), Drawing->hContact); break; case SETTING_AVATAR_OVERLAY_TYPE_CONTACT: overlayIdx = Drawing->iImage; @@ -2548,7 +2548,7 @@ void CLCPaint::_DrawContactAvatar(HDC hdcMem, ClcData *dat, ClcContact *Drawing, break; case SETTING_AVATAR_OVERLAY_TYPE_PROTOCOL: { - int item = g_clistApi.pfnIconFromStatusMode(Drawing->proto, Drawing->proto == nullptr ? ID_STATUS_OFFLINE : GetContactCachedStatus(Drawing->hContact), Drawing->hContact); + int item = g_clistApi.pfnIconFromStatusMode(Drawing->pce->szProto, Drawing->pce->szProto == nullptr ? ID_STATUS_OFFLINE : GetContactCachedStatus(Drawing->hContact), Drawing->hContact); if (item != -1) _DrawStatusIcon(Drawing, dat, item, hdcMem, ptOverlay.x, ptOverlay.y, ICON_HEIGHT, ICON_HEIGHT, diff --git a/plugins/Clist_modern/src/modern_clcutils.cpp b/plugins/Clist_modern/src/modern_clcutils.cpp index 8c24177588..aeb2aca4bf 100644 --- a/plugins/Clist_modern/src/modern_clcutils.cpp +++ b/plugins/Clist_modern/src/modern_clcutils.cpp @@ -407,7 +407,7 @@ int GetDropTargetInformation(HWND hwnd, ClcData *dat, POINT pt) } dat->selection = hit; - if (!mir_strcmp(contact->proto, META_PROTO)) + if (!mir_strcmp(contact->pce->szProto, META_PROTO)) return DROPTARGET_ONMETACONTACT; if (contact->iSubNumber) return DROPTARGET_ONSUBCONTACT; diff --git a/plugins/Clist_modern/src/modern_contact.cpp b/plugins/Clist_modern/src/modern_contact.cpp index b44777478a..bbd309e280 100644 --- a/plugins/Clist_modern/src/modern_contact.cpp +++ b/plugins/Clist_modern/src/modern_contact.cpp @@ -125,9 +125,9 @@ int cliCompareContacts(const ClcContact *contact1, const ClcContact *contact2) break; case SORTBY_PROTO: - if (contact1->proto == nullptr || contact2->proto == nullptr) + if (contact1->pce->szProto == nullptr || contact2->pce->szProto == nullptr) continue; - r = GetProtoIndex(contact1->proto) - GetProtoIndex(contact2->proto); + r = GetProtoIndex(contact1->pce->szProto) - GetProtoIndex(contact2->pce->szProto); break; case SORTBY_RATE: -- cgit v1.2.3