From 15267ea2d489606fb4b99d011bc3ea7c2a644a9f Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 17 Mar 2013 14:22:17 +0000 Subject: fix for popup-related memory leaks git-svn-id: http://svn.miranda-ng.org/main/trunk@4077 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Ping/src/utils.cpp | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'plugins/Ping') diff --git a/plugins/Ping/src/utils.cpp b/plugins/Ping/src/utils.cpp index 972d60845c..c87793fee8 100644 --- a/plugins/Ping/src/utils.cpp +++ b/plugins/Ping/src/utils.cpp @@ -300,11 +300,16 @@ void import_ping_addresses() LeaveCriticalSection(&list_cs); } -HANDLE hIcoLibIconsChanged; +HANDLE hPopupClass; +HICON hIconResponding, hIconNotResponding, hIconTesting, hIconDisabled; -HICON hIconResponding, hIconNotResponding, hIconTesting, hIconDisabled; +static int OnShutdown(WPARAM, LPARAM) +{ + Popup_UnregisterClass(hPopupClass); + return 0; +} -int ReloadIcons(WPARAM wParam, LPARAM lParam) +static int ReloadIcons(WPARAM wParam, LPARAM lParam) { hIconResponding = Skin_GetIcon("ping_responding"); hIconNotResponding = Skin_GetIcon("ping_not_responding"); @@ -332,16 +337,15 @@ void InitUtils() hIconTesting = Skin_GetIcon("ping_testing"); hIconDisabled = Skin_GetIcon("ping_disabled"); - hIcoLibIconsChanged = HookEvent(ME_SKIN2_ICONSCHANGED, ReloadIcons); - - if (ServiceExists(MS_POPUP_REGISTERCLASS)) { - POPUPCLASS test = { sizeof(test) }; - test.flags = PCF_TCHAR; - test.hIcon = hIconResponding; - test.iSeconds = -1; - test.ptszDescription = TranslateT("Ping"); - test.pszName = "pingpopups"; - test.PluginWindowProc = NullWindowProc; - CallService(MS_POPUP_REGISTERCLASS, 0, (WPARAM)&test); - } + HookEvent(ME_SKIN2_ICONSCHANGED, ReloadIcons); + + POPUPCLASS test = { sizeof(test) }; + test.flags = PCF_TCHAR; + test.hIcon = hIconResponding; + test.iSeconds = -1; + test.ptszDescription = TranslateT("Ping"); + test.pszName = "pingpopups"; + test.PluginWindowProc = NullWindowProc; + if (hPopupClass = Popup_RegisterClass(&test)) + HookEvent(ME_SYSTEM_PRESHUTDOWN, OnShutdown); } -- cgit v1.2.3