diff options
author | Jon TURNEY <jon.turney@dronecode.org.uk> | 2010-07-22 18:36:51 +0100 |
---|---|---|
committer | Jon TURNEY <jon.turney@dronecode.org.uk> | 2010-08-13 14:59:19 +0100 |
commit | 7bb1d96c06c27da4bf11c02889600a215f5391f7 (patch) | |
tree | b5b5c06a631e557065958f63f8b7d7094e83a607 | |
parent | f7627e5e4ed9698b3a5fc2fe2de388573571c984 (diff) |
Cygwin/X: Fix a GDI bitmap resource leak of window icons
Ensure any icon created specially for a window is destroyed when
the window is destroyed
-rw-r--r-- | hw/xwin/winmultiwindowicons.c | 3 | ||||
-rw-r--r-- | hw/xwin/winmultiwindowwindow.c | 13 | ||||
-rwxr-xr-x | hw/xwin/winwin32rootless.c | 20 |
3 files changed, 24 insertions, 12 deletions
diff --git a/hw/xwin/winmultiwindowicons.c b/hw/xwin/winmultiwindowicons.c index cb27d2fe3..86ad51ee2 100644 --- a/hw/xwin/winmultiwindowicons.c +++ b/hw/xwin/winmultiwindowicons.c @@ -631,6 +631,7 @@ void winSelectIcons(WindowPtr pWin, HICON *pIcon, HICON *pSmallIcon) *pIcon = hIcon; else winDestroyIcon(hIcon); + if (pSmallIcon) *pSmallIcon = hSmallIcon; else @@ -639,7 +640,7 @@ void winSelectIcons(WindowPtr pWin, HICON *pIcon, HICON *pSmallIcon) void winDestroyIcon(HICON hIcon) { - /* Delete the icon if its not the default */ + /* Delete the icon if its not one of the application defaults or an override */ if (hIcon && hIcon != g_hIconX && hIcon != g_hSmallIconX && diff --git a/hw/xwin/winmultiwindowwindow.c b/hw/xwin/winmultiwindowwindow.c index 8cb6c668a..0dd81f476 100644 --- a/hw/xwin/winmultiwindowwindow.c +++ b/hw/xwin/winmultiwindowwindow.c @@ -617,7 +617,9 @@ winDestroyWindowsWindow (WindowPtr pWin) MSG msg; winWindowPriv(pWin); BOOL oldstate = winInDestroyWindowsWindow; - + HICON hIcon; + HICON hIconSm; + #if CYGMULTIWINDOW_DEBUG ErrorF ("winDestroyWindowsWindow\n"); #endif @@ -628,13 +630,22 @@ winDestroyWindowsWindow (WindowPtr pWin) winInDestroyWindowsWindow = TRUE; + /* Store the info we need to destroy after this window is gone */ + hIcon = (HICON)SendMessage(pWinPriv->hWnd, WM_GETICON, ICON_BIG, 0); + hIconSm = (HICON)SendMessage(pWinPriv->hWnd, WM_GETICON, ICON_SMALL, 0); + SetProp (pWinPriv->hWnd, WIN_WINDOW_PROP, NULL); + /* Destroy the Windows window */ DestroyWindow (pWinPriv->hWnd); /* Null our handle to the Window so referencing it will cause an error */ pWinPriv->hWnd = NULL; + /* Destroy any icons we created for this window */ + winDestroyIcon(hIcon); + winDestroyIcon(hIconSm); + /* Process all messages on our queue */ while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) { diff --git a/hw/xwin/winwin32rootless.c b/hw/xwin/winwin32rootless.c index 9749861fd..6a8d91c1e 100755 --- a/hw/xwin/winwin32rootless.c +++ b/hw/xwin/winwin32rootless.c @@ -367,8 +367,8 @@ void winMWExtWMDestroyFrame (RootlessFrameID wid) { win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid; - HICON hiconClass; - HICON hiconSmClass; + HICON hIcon; + HICON hIconSm; HMODULE hInstance; int iReturn; char pszClass[CLASS_NAME_LENGTH]; @@ -399,8 +399,8 @@ winMWExtWMDestroyFrame (RootlessFrameID wid) /* Store the info we need to destroy after this window is gone */ hInstance = (HINSTANCE) GetClassLongPtr (pRLWinPriv->hWnd, GCLP_HMODULE); - hiconClass = (HICON) GetClassLongPtr (pRLWinPriv->hWnd, GCLP_HICON); - hiconSmClass = (HICON) GetClassLongPtr (pRLWinPriv->hWnd, GCLP_HICONSM); + hIcon = (HICON)SendMessage(pRLWinPriv->hWnd, WM_GETICON, ICON_BIG, 0); + hIconSm = (HICON)SendMessage(pRLWinPriv->hWnd, WM_GETICON, ICON_SMALL, 0); iReturn = GetClassName (pRLWinPriv->hWnd, pszClass, CLASS_NAME_LENGTH); pRLWinPriv->fClose = TRUE; @@ -416,14 +416,14 @@ winMWExtWMDestroyFrame (RootlessFrameID wid) winDebug ("winMWExtWMDestroyFrame - Unregistering %s: ", pszClass); #endif iReturn = UnregisterClass (pszClass, hInstance); - + } + #if CYGMULTIWINDOW_DEBUG - winDebug ("winMWExtWMDestroyFramew - %d Deleting Icon: ", iReturn); + winDebug ("winMWExtWMDestroyFramew - Deleting Icon\n"); #endif - - winDestroyIcon(hiconClass); - winDestroyIcon(hiconSmClass); - } + + winDestroyIcon(hIcon); + winDestroyIcon(hIconSm); #if CYGMULTIWINDOW_DEBUG winDebug ("winMWExtWMDestroyFrame - done\n"); |