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 Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk> Reviewed-by: Colin Harrison <colin.harrison@virgin.net> Tested-by: Colin Harrison <colin.harrison@virgin.net>
This commit is contained in:
parent
19e764eee0
commit
bd288c3458
|
@ -624,6 +624,7 @@ void winSelectIcons(WindowPtr pWin, HICON *pIcon, HICON *pSmallIcon)
|
||||||
*pIcon = hIcon;
|
*pIcon = hIcon;
|
||||||
else
|
else
|
||||||
winDestroyIcon(hIcon);
|
winDestroyIcon(hIcon);
|
||||||
|
|
||||||
if (pSmallIcon)
|
if (pSmallIcon)
|
||||||
*pSmallIcon = hSmallIcon;
|
*pSmallIcon = hSmallIcon;
|
||||||
else
|
else
|
||||||
|
@ -632,7 +633,7 @@ void winSelectIcons(WindowPtr pWin, HICON *pIcon, HICON *pSmallIcon)
|
||||||
|
|
||||||
void winDestroyIcon(HICON hIcon)
|
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 &&
|
if (hIcon &&
|
||||||
hIcon != g_hIconX &&
|
hIcon != g_hIconX &&
|
||||||
hIcon != g_hSmallIconX &&
|
hIcon != g_hSmallIconX &&
|
||||||
|
|
|
@ -592,6 +592,8 @@ winDestroyWindowsWindow (WindowPtr pWin)
|
||||||
MSG msg;
|
MSG msg;
|
||||||
winWindowPriv(pWin);
|
winWindowPriv(pWin);
|
||||||
BOOL oldstate = winInDestroyWindowsWindow;
|
BOOL oldstate = winInDestroyWindowsWindow;
|
||||||
|
HICON hIcon;
|
||||||
|
HICON hIconSm;
|
||||||
|
|
||||||
#if CYGMULTIWINDOW_DEBUG
|
#if CYGMULTIWINDOW_DEBUG
|
||||||
ErrorF ("winDestroyWindowsWindow\n");
|
ErrorF ("winDestroyWindowsWindow\n");
|
||||||
|
@ -603,13 +605,22 @@ winDestroyWindowsWindow (WindowPtr pWin)
|
||||||
|
|
||||||
winInDestroyWindowsWindow = TRUE;
|
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);
|
SetProp (pWinPriv->hWnd, WIN_WINDOW_PROP, NULL);
|
||||||
|
|
||||||
/* Destroy the Windows window */
|
/* Destroy the Windows window */
|
||||||
DestroyWindow (pWinPriv->hWnd);
|
DestroyWindow (pWinPriv->hWnd);
|
||||||
|
|
||||||
/* Null our handle to the Window so referencing it will cause an error */
|
/* Null our handle to the Window so referencing it will cause an error */
|
||||||
pWinPriv->hWnd = NULL;
|
pWinPriv->hWnd = NULL;
|
||||||
|
|
||||||
|
/* Destroy any icons we created for this window */
|
||||||
|
winDestroyIcon(hIcon);
|
||||||
|
winDestroyIcon(hIconSm);
|
||||||
|
|
||||||
/* Process all messages on our queue */
|
/* Process all messages on our queue */
|
||||||
while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
|
while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
|
||||||
{
|
{
|
||||||
|
|
|
@ -366,8 +366,8 @@ void
|
||||||
winMWExtWMDestroyFrame (RootlessFrameID wid)
|
winMWExtWMDestroyFrame (RootlessFrameID wid)
|
||||||
{
|
{
|
||||||
win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
|
win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
|
||||||
HICON hiconClass;
|
HICON hIcon;
|
||||||
HICON hiconSmClass;
|
HICON hIconSm;
|
||||||
HMODULE hInstance;
|
HMODULE hInstance;
|
||||||
int iReturn;
|
int iReturn;
|
||||||
char pszClass[CLASS_NAME_LENGTH];
|
char pszClass[CLASS_NAME_LENGTH];
|
||||||
|
@ -398,8 +398,8 @@ winMWExtWMDestroyFrame (RootlessFrameID wid)
|
||||||
|
|
||||||
/* Store the info we need to destroy after this window is gone */
|
/* Store the info we need to destroy after this window is gone */
|
||||||
hInstance = (HINSTANCE) GetClassLongPtr (pRLWinPriv->hWnd, GCLP_HMODULE);
|
hInstance = (HINSTANCE) GetClassLongPtr (pRLWinPriv->hWnd, GCLP_HMODULE);
|
||||||
hiconClass = (HICON) GetClassLongPtr (pRLWinPriv->hWnd, GCLP_HICON);
|
hIcon = (HICON)SendMessage(pRLWinPriv->hWnd, WM_GETICON, ICON_BIG, 0);
|
||||||
hiconSmClass = (HICON) GetClassLongPtr (pRLWinPriv->hWnd, GCLP_HICONSM);
|
hIconSm = (HICON)SendMessage(pRLWinPriv->hWnd, WM_GETICON, ICON_SMALL, 0);
|
||||||
iReturn = GetClassName (pRLWinPriv->hWnd, pszClass, CLASS_NAME_LENGTH);
|
iReturn = GetClassName (pRLWinPriv->hWnd, pszClass, CLASS_NAME_LENGTH);
|
||||||
|
|
||||||
pRLWinPriv->fClose = TRUE;
|
pRLWinPriv->fClose = TRUE;
|
||||||
|
@ -415,14 +415,14 @@ winMWExtWMDestroyFrame (RootlessFrameID wid)
|
||||||
winDebug ("winMWExtWMDestroyFrame - Unregistering %s: ", pszClass);
|
winDebug ("winMWExtWMDestroyFrame - Unregistering %s: ", pszClass);
|
||||||
#endif
|
#endif
|
||||||
iReturn = UnregisterClass (pszClass, hInstance);
|
iReturn = UnregisterClass (pszClass, hInstance);
|
||||||
|
}
|
||||||
|
|
||||||
#if CYGMULTIWINDOW_DEBUG
|
#if CYGMULTIWINDOW_DEBUG
|
||||||
winDebug ("winMWExtWMDestroyFramew - %d Deleting Icon: ", iReturn);
|
winDebug ("winMWExtWMDestroyFramew - Deleting Icon\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
winDestroyIcon(hiconClass);
|
winDestroyIcon(hIcon);
|
||||||
winDestroyIcon(hiconSmClass);
|
winDestroyIcon(hIconSm);
|
||||||
}
|
|
||||||
|
|
||||||
#if CYGMULTIWINDOW_DEBUG
|
#if CYGMULTIWINDOW_DEBUG
|
||||||
winDebug ("winMWExtWMDestroyFrame - done\n");
|
winDebug ("winMWExtWMDestroyFrame - done\n");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user