diff options
author | George Hazan <ghazan@miranda.im> | 2022-02-21 22:37:17 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2022-02-21 22:37:17 +0300 |
commit | 53d520d37b62d9d99ac22c933895ec31f7f13546 (patch) | |
tree | 5fd4f49ac9aa3fc584271874ffb7611a546dd2ce /plugins/AVS/src | |
parent | 447334def7efa0eafe421cf12ad7490b35f775bc (diff) |
fixes #3043 (AVS: удалённые аватары не появляются при обновлении данных)
Diffstat (limited to 'plugins/AVS/src')
-rw-r--r-- | plugins/AVS/src/options.cpp | 31 |
1 files 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; } |