From db937fbda0117e8bec530e7deda7b94eea106e78 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 22 Jul 2020 20:47:51 +0300 Subject: to #2492: we also need to free a session when a contact gets deleted --- src/mir_app/src/chat.h | 2 ++ src/mir_app/src/chat_manager.cpp | 13 +++++++++++++ src/mir_app/src/clistsettings.cpp | 2 ++ 3 files changed, 17 insertions(+) (limited to 'src') diff --git a/src/mir_app/src/chat.h b/src/mir_app/src/chat.h index 81675c46ad..e3fa0461fa 100644 --- a/src/mir_app/src/chat.h +++ b/src/mir_app/src/chat.h @@ -122,6 +122,8 @@ int ShowPopup(MCONTACT hContact, SESSION_INFO *si, HICON hIcon, char* CSrmmLogWindow *Srmm_GetLogWindow(CMsgDialog *pDlg); +void Chat_RemoveContact(MCONTACT hContact); + const wchar_t* my_strstri(const wchar_t* s1, const wchar_t* s2); #pragma comment(lib,"comctl32.lib") diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp index 3111d6f548..8be8100efb 100644 --- a/src/mir_app/src/chat_manager.cpp +++ b/src/mir_app/src/chat_manager.cpp @@ -978,6 +978,19 @@ MIR_APP_DLL(CHAT_MANAGER*) Chat_CustomizeApi(const CHAT_MANAGER_INITDATA *pInit) ///////////////////////////////////////////////////////////////////////////////////////// +void Chat_RemoveContact(MCONTACT hContact) +{ + for (auto &si : g_arSessions) { + if (si->hContact == hContact) { + SM_FreeSession(si); + g_arSessions.removeItem(&si); + break; + } + } +} + +///////////////////////////////////////////////////////////////////////////////////////// + CHAT_MANAGER::CHAT_MANAGER() : arSessions(g_arSessions) { diff --git a/src/mir_app/src/clistsettings.cpp b/src/mir_app/src/clistsettings.cpp index 907a3c93b5..fe7013d852 100644 --- a/src/mir_app/src/clistsettings.cpp +++ b/src/mir_app/src/clistsettings.cpp @@ -24,6 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h" #include "clc.h" +#include "chat.h" static LIST clistCache(50, NumericKeySortT); @@ -159,6 +160,7 @@ int ContactDeleted(WPARAM hContact, LPARAM) if (it->hContact == hContact) g_clistApi.pfnRemoveEvent(hContact, it->hDbEvent); + Chat_RemoveContact(hContact); return 0; } -- cgit v1.2.3