From f04b54e3fc162d475e8688784631a316f264f733 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 21 May 2023 14:56:39 +0300 Subject: Clist_RemoveEvent became static, pfnRemoveEvent is replaced with pfnFreeEvent --- plugins/Clist_modern/src/init.cpp | 2 +- plugins/Clist_modern/src/modern_clistevents.cpp | 20 ++++++-------------- plugins/Clist_modern/src/modern_commonprototypes.h | 2 +- 3 files changed, 8 insertions(+), 16 deletions(-) (limited to 'plugins/Clist_modern') diff --git a/plugins/Clist_modern/src/init.cpp b/plugins/Clist_modern/src/init.cpp index 6e809c6b4b..851076a1c5 100644 --- a/plugins/Clist_modern/src/init.cpp +++ b/plugins/Clist_modern/src/init.cpp @@ -206,7 +206,7 @@ static HRESULT SubclassClistInterface() g_clistApi.pfnContactListControlWndProc = cli_ContactListControlWndProc; g_clistApi.pfnProcessExternalMessages = cli_ProcessExternalMessages; g_clistApi.pfnAddEvent = cli_AddEvent; - g_clistApi.pfnRemoveEvent = cli_RemoveEvent; + g_clistApi.pfnFreeEvent = cli_RemoveEvent; g_clistApi.pfnDocking_ProcessWindowMessage = Docking_ProcessWindowMessage; return S_OK; } diff --git a/plugins/Clist_modern/src/modern_clistevents.cpp b/plugins/Clist_modern/src/modern_clistevents.cpp index e918bcee65..d0eb4753d2 100644 --- a/plugins/Clist_modern/src/modern_clistevents.cpp +++ b/plugins/Clist_modern/src/modern_clistevents.cpp @@ -155,19 +155,11 @@ CListEvent* cli_AddEvent(CLISTEVENT *cle) } -int cli_RemoveEvent(MCONTACT hContact, MEVENT hDbEvent) +int cli_RemoveEvent(CListEvent *pEvent) { - // Find the event that should be removed - CListEvent *pEvent = nullptr; - for (auto &it : *g_clistApi.events) - if (it->hContact == hContact && it->hDbEvent == hDbEvent) { - pEvent = it; - break; - } - - // Event was not found - if (pEvent == nullptr) - return 1; + // save variables because pEvent should be freed + auto hContact = pEvent->hContact; + auto hDbEvent = pEvent->hDbEvent; // remove event from the notify menu int iMenuId = pEvent->menuId; @@ -184,7 +176,7 @@ int cli_RemoveEvent(MCONTACT hContact, MEVENT hDbEvent) } } - int res = corecli.pfnRemoveEvent(hContact, hDbEvent); + int res = corecli.pfnFreeEvent(pEvent); if (g_clistApi.events->getCount() == 0) { g_CluiData.bNotifyActive = false; @@ -407,7 +399,7 @@ static LRESULT CALLBACK EventArea_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LP // event we're interested in was removed by the service (nasty one...) cle1 = MyGetEvent(iSelection); if (cle1 != nullptr) - g_clistApi.pfnRemoveEvent(cle->hContact, cle->hDbEvent); + Clist_RemoveEvent(cle->hContact, cle->hDbEvent); } } } diff --git a/plugins/Clist_modern/src/modern_commonprototypes.h b/plugins/Clist_modern/src/modern_commonprototypes.h index 78cc984508..69c0264136 100644 --- a/plugins/Clist_modern/src/modern_commonprototypes.h +++ b/plugins/Clist_modern/src/modern_commonprototypes.h @@ -214,7 +214,7 @@ int cliGetGroupContentsCount(ClcGroup *group, int visibleOnly); int cliFindRowByText(HWND hwnd, ClcData *dat, const wchar_t *text, int prefixOk); int cliGetRowsPriorTo(ClcGroup *group, ClcGroup *subgroup, int contactIndex); int cli_IconFromStatusMode(const char *szProto, int nStatus, MCONTACT hContact); -int cli_RemoveEvent(MCONTACT hContact, MEVENT hDbEvent); +int cli_RemoveEvent(CListEvent *cle); void cli_FreeContact(ClcContact*); void cli_SetContactCheckboxes(ClcContact*, int); LRESULT cli_ProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wParam, LPARAM lParam); -- cgit v1.2.3