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_nicer/src/clc.cpp | 6 +++--- plugins/Clist_nicer/src/clc.h | 3 +++ plugins/Clist_nicer/src/clcitems.cpp | 16 ++++++++-------- plugins/Clist_nicer/src/clistmenus.cpp | 4 ++-- plugins/Clist_nicer/src/contact.cpp | 9 ++++----- 5 files changed, 20 insertions(+), 18 deletions(-) (limited to 'plugins/Clist_nicer/src') diff --git a/plugins/Clist_nicer/src/clc.cpp b/plugins/Clist_nicer/src/clc.cpp index cbc7fe3c7f..f26da696c6 100644 --- a/plugins/Clist_nicer/src/clc.cpp +++ b/plugins/Clist_nicer/src/clc.cpp @@ -464,7 +464,7 @@ LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, L p = cfg::getCache(wParam, nullptr); else { p = contact->pExtra; - szProto = contact->proto; + szProto = contact->pce->szProto; } GetCachedStatusMsg(p, szProto); PostMessage(hwnd, INTM_INVALIDATE, 0, contact ? contact->hContact : 0); @@ -473,7 +473,7 @@ LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, L case INTM_STATUSCHANGED: if (Clist_FindItem(hwnd, dat, wParam, &contact, nullptr, nullptr)) { - WORD wStatus = db_get_w(wParam, contact->proto, "Status", ID_STATUS_OFFLINE); + WORD wStatus = db_get_w(wParam, contact->pce->szProto, "Status", ID_STATUS_OFFLINE); if (cfg::dat.bNoOfflineAvatars && wStatus != ID_STATUS_OFFLINE && contact->wStatus == ID_STATUS_OFFLINE) { contact->wStatus = wStatus; if (cfg::dat.bAvatarServiceAvail && contact->ace == nullptr) @@ -488,7 +488,7 @@ LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, L if (!Clist_FindItem(hwnd, dat, wParam, &contact, nullptr, nullptr)) break; - contact->proto = GetContactProto(wParam); + contact->pce->szProto = GetContactProto(wParam); g_clistApi.pfnInvalidateDisplayNameCacheEntry(wParam); mir_wstrncpy(contact->szText, Clist_GetContactDisplayName(wParam), _countof(contact->szText)); diff --git a/plugins/Clist_nicer/src/clc.h b/plugins/Clist_nicer/src/clc.h index c7ccfd1c7f..0b2a09be22 100644 --- a/plugins/Clist_nicer/src/clc.h +++ b/plugins/Clist_nicer/src/clc.h @@ -117,6 +117,9 @@ struct TExtraCache BOOL isChatRoom; }; +struct ClcCacheEntry : public ClcCacheEntryBase +{}; + struct ClcContact : public ClcContactBase { BOOL bIsMeta; diff --git a/plugins/Clist_nicer/src/clcitems.cpp b/plugins/Clist_nicer/src/clcitems.cpp index d415dfb92d..095ba1e2eb 100644 --- a/plugins/Clist_nicer/src/clcitems.cpp +++ b/plugins/Clist_nicer/src/clcitems.cpp @@ -96,11 +96,11 @@ ClcContact* AddContactToGroup(struct ClcData *dat, ClcGroup *group, MCONTACT hCo { ClcContact *p = coreCli.pfnAddContactToGroup(dat, group, hContact); - p->wStatus = db_get_w(hContact, p->proto, "Status", ID_STATUS_OFFLINE); - p->xStatus = db_get_b(hContact, p->proto, "XStatusId", 0); + p->wStatus = db_get_w(hContact, p->pce->szProto, "Status", ID_STATUS_OFFLINE); + p->xStatus = db_get_b(hContact, p->pce->szProto, "XStatusId", 0); - if (p->proto) - p->bIsMeta = !mir_strcmp(p->proto, META_PROTO); + if (p->pce->szProto) + p->bIsMeta = !mir_strcmp(p->pce->szProto, META_PROTO); else p->bIsMeta = FALSE; if (p->bIsMeta && !(cfg::dat.dwFlags & CLUI_USEMETAICONS)) { @@ -119,10 +119,10 @@ ClcContact* AddContactToGroup(struct ClcData *dat, ClcGroup *group, MCONTACT hCo if (dat->bisEmbedded) p->pExtra = nullptr; else { - p->pExtra = cfg::getCache(p->hContact, p->proto); + p->pExtra = cfg::getCache(p->hContact, p->pce->szProto); GetExtendedInfo(p, dat); if (p->pExtra) - p->pExtra->proto_status_item = GetProtocolStatusItem(p->bIsMeta ? p->metaProto : p->proto); + p->pExtra->proto_status_item = GetProtocolStatusItem(p->bIsMeta ? p->metaProto : p->pce->szProto); LoadAvatarForContact(p); // notify other plugins to re-supply their extra images (icq for xstatus, mBirthday etc...) @@ -317,7 +317,7 @@ void GetExtendedInfo(ClcContact *contact, ClcData *dat) if (dat->bisEmbedded || contact == nullptr) return; - if (contact->proto == nullptr || contact->hContact == 0) + if (contact->pce->szProto == nullptr || contact->hContact == 0) return; TExtraCache *p = contact->pExtra; @@ -329,7 +329,7 @@ void GetExtendedInfo(ClcContact *contact, ClcData *dat) return; p->valid = TRUE; - p->isChatRoom = db_get_b(contact->hContact, contact->proto, "ChatRoom", 0); + p->isChatRoom = db_get_b(contact->hContact, contact->pce->szProto, "ChatRoom", 0); } void LoadSkinItemToCache(TExtraCache *cEntry) diff --git a/plugins/Clist_nicer/src/clistmenus.cpp b/plugins/Clist_nicer/src/clistmenus.cpp index 28a8555f09..a5fd27c1fe 100644 --- a/plugins/Clist_nicer/src/clistmenus.cpp +++ b/plugins/Clist_nicer/src/clistmenus.cpp @@ -105,7 +105,7 @@ static INT_PTR CALLBACK IgnoreDialogProc(HWND hWnd, UINT msg, WPARAM wParam, LPA SetWindowText(hWnd, szTitle); Window_SetSkinIcon_IcoLib(hWnd, SKINICON_OTHER_MIRANDA); - pCaps = CallProtoService(contact ? contact->proto : GetContactProto(hContact), PS_GETCAPS, PFLAGNUM_1, 0); + pCaps = CallProtoService(contact ? contact->pce->szProto : GetContactProto(hContact), PS_GETCAPS, PFLAGNUM_1, 0); Utils::enableDlgControl(hWnd, IDC_IGN_ALWAYSONLINE, pCaps & PF1_INVISLIST ? TRUE : FALSE); Utils::enableDlgControl(hWnd, IDC_IGN_ALWAYSOFFLINE, pCaps & PF1_VISLIST ? TRUE : FALSE); CheckDlgButton(hWnd, IDC_IGN_PRIORITY, db_get_b(hContact, "CList", "Priority", 0) ? BST_CHECKED : BST_UNCHECKED); @@ -287,7 +287,7 @@ static INT_PTR CALLBACK IgnoreDialogProc(HWND hWnd, UINT msg, WPARAM wParam, LPA ClcContact *contact = nullptr; if (Clist_FindItem(g_clistApi.hwndContactTree, cfg::clcdat, hContact, &contact, nullptr, nullptr)) { if (contact) { - WORD wApparentMode = db_get_w(contact->hContact, contact->proto, "ApparentMode", 0); + WORD wApparentMode = db_get_w(contact->hContact, contact->pce->szProto, "ApparentMode", 0); CheckDlgButton(hWnd, IDC_IGN_ALWAYSOFFLINE, wApparentMode == ID_STATUS_OFFLINE ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hWnd, IDC_IGN_ALWAYSONLINE, wApparentMode == ID_STATUS_ONLINE ? BST_CHECKED : BST_UNCHECKED); diff --git a/plugins/Clist_nicer/src/contact.cpp b/plugins/Clist_nicer/src/contact.cpp index 9e3933a039..e3b4016a02 100644 --- a/plugins/Clist_nicer/src/contact.cpp +++ b/plugins/Clist_nicer/src/contact.cpp @@ -160,14 +160,13 @@ int __forceinline INTSORT_CompareContacts(const ClcContact* c1, const ClcContact { wchar_t *namea, *nameb; int statusa, statusb; - char *szProto1, *szProto2; int rc; if (c1 == nullptr || c2 == nullptr) return 0; - szProto1 = c1->proto; - szProto2 = c2->proto; + char *szProto1 = c1->pce->szProto; + char *szProto2 = c2->pce->szProto; statusa = c1->wStatus; statusb = c2->wStatus; // make sure, sticky contacts are always at the beginning of the group/list @@ -221,9 +220,9 @@ int __forceinline INTSORT_CompareContacts(const ClcContact* c1, const ClcContact case SORTBY_PROTO: if (c1->bIsMeta) - szProto1 = c1->metaProto ? c1->metaProto : c1->proto; + szProto1 = c1->metaProto ? c1->metaProto : c1->pce->szProto; if (c2->bIsMeta) - szProto2 = c2->metaProto ? c2->metaProto : c2->proto; + szProto2 = c2->metaProto ? c2->metaProto : c2->pce->szProto; rc = GetProtoIndex(szProto1) - GetProtoIndex(szProto2); -- cgit v1.2.3