From 53d520d37b62d9d99ac22c933895ec31f7f13546 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 21 Feb 2022 22:37:17 +0300 Subject: =?UTF-8?q?fixes=20#3043=20(AVS:=20=D1=83=D0=B4=D0=B0=D0=BB=D1=91?= =?UTF-8?q?=D0=BD=D0=BD=D1=8B=D0=B5=20=D0=B0=D0=B2=D0=B0=D1=82=D0=B0=D1=80?= =?UTF-8?q?=D1=8B=20=D0=BD=D0=B5=20=D0=BF=D0=BE=D1=8F=D0=B2=D0=BB=D1=8F?= =?UTF-8?q?=D1=8E=D1=82=D1=81=D1=8F=20=D0=BF=D1=80=D0=B8=20=D0=BE=D0=B1?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B8=20=D0=B4=D0=B0?= =?UTF-8?q?=D0=BD=D0=BD=D1=8B=D1=85)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/AVS/src/options.cpp | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/plugins/AVS/src/options.cpp b/plugins/AVS/src/options.cpp index e0aa64fc69..ef355a951d 100644 --- a/plugins/AVS/src/options.cpp +++ b/plugins/AVS/src/options.cpp @@ -39,8 +39,19 @@ static BOOL dialoginit = TRUE; struct WindowData { + WindowData(MCONTACT _1, HWND hwndDlg) : + hContact(_1) + { + hHook = HookEventMessage(ME_AV_AVATARCHANGED, hwndDlg, DM_AVATARCHANGED); + } + + ~WindowData() + { + UnhookEvent(hHook); + } + MCONTACT hContact; - HANDLE hHook; + HANDLE hHook = nullptr; }; static void RemoveProtoPic(protoPicCacheEntry *pce) @@ -481,8 +492,7 @@ INT_PTR CALLBACK DlgProcAvatarOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPA switch (msg) { case WM_INITDIALOG: - dat = (WindowData*)malloc(sizeof(WindowData)); - dat->hContact = hContact = lParam; + dat = new WindowData(hContact = lParam, hwndDlg); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); TranslateDialogDefault(hwndDlg); @@ -504,7 +514,6 @@ INT_PTR CALLBACK DlgProcAvatarOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPA SendDlgItemMessage(hwndDlg, IDC_BKG_COLOR_DIFFERENCE_SPIN, UDM_SETRANGE, 0, MAKELONG(100, 0)); LoadTransparentData(hwndDlg, GetContactThatHaveTheAvatar(hContact)); - dat->hHook = HookEventMessage(ME_AV_AVATARCHANGED, hwndDlg, DM_AVATARCHANGED); SendMessage(hwndDlg, WM_SETICON, IMAGE_ICON, (LPARAM)g_hIcon); return TRUE; @@ -691,10 +700,7 @@ INT_PTR CALLBACK DlgProcAvatarOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPA break; case WM_NCDESTROY: - if (dat) { - UnhookEvent(dat->hHook); - free(dat); - } + delete dat; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0); break; } @@ -734,8 +740,7 @@ static INT_PTR CALLBACK DlgProcAvatarUserInfo(HWND hwndDlg, UINT msg, WPARAM wPa switch (msg) { case WM_INITDIALOG: - dat = (WindowData*)malloc(sizeof(WindowData)); - dat->hContact = hContact = lParam; + dat = new WindowData(hContact = lParam, hwndDlg); { HWND protopic = GetDlgItem(hwndDlg, IDC_PROTOPIC); SendMessage(protopic, AVATAR_SETCONTACT, 0, (LPARAM)hContact); @@ -862,8 +867,12 @@ static INT_PTR CALLBACK DlgProcAvatarUserInfo(HWND hwndDlg, UINT msg, WPARAM wPa ChangeAvatar(hContact, true); break; + case DM_AVATARCHANGED: + InvalidateRect(GetDlgItem(hwndDlg, IDC_PROTOPIC), nullptr, TRUE); + break; + case WM_NCDESTROY: - free(dat); + delete dat; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0); break; } -- cgit v1.2.3