Fix MWExtWM resource leak.

This commit is contained in:
Kensuke Matsuzaki 2004-04-10 23:18:09 +00:00
parent cb5729490b
commit 9915cfc156
4 changed files with 45 additions and 4 deletions

View file

@ -620,8 +620,6 @@ winDestroyWindowsWindow (WindowPtr pWin)
if (pWinPriv->hWnd == NULL)
return;
SetProp (pWinPriv->hWnd, WIN_WINDOW_PROP, 0);
/* Store the info we need to destroy after this window is gone */
hInstance = (HINSTANCE) GetClassLong (pWinPriv->hWnd, GCL_HMODULE);
hiconClass = (HICON) GetClassLong (pWinPriv->hWnd, GCL_HICON);

View file

@ -799,6 +799,10 @@ winTopLevelWindowProc (HWND hwnd, UINT message,
winSendMessageToWM (s_pScreenPriv->pWMInfo, &wmMsg);
}
RemoveProp (hwnd, WIN_WINDOW_PROP);
RemoveProp (hwnd, WIN_WID_PROP);
RemoveProp (hwnd, WIN_NEEDMANAGE_PROP);
#if CYGMULTIWINDOW_DEBUG
ErrorF ("winTopLevelWindowProc - WM_DESTROY\n");
#endif

View file

@ -241,6 +241,7 @@ winMWExtWMCreateFrame (RootlessWindowPtr pFrame, ScreenPtr pScreen,
pRLWinPriv->hbmpShadow = NULL;
pRLWinPriv->hdcShadow = NULL;
pRLWinPriv->hdcScreen = NULL;
pRLWinPriv->pbmihShadow = NULL;
pRLWinPriv->fResized = TRUE;
pRLWinPriv->fClose = FALSE;
pRLWinPriv->fRestackingNow = FALSE;
@ -377,6 +378,11 @@ void
winMWExtWMDestroyFrame (RootlessFrameID wid)
{
win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
HICON hiconClass;
HMODULE hInstance;
int iReturn;
char pszClass[CLASS_NAME_LENGTH];
#if CYGMULTIWINDOW_DEBUG
ErrorF ("winMWExtWMDestroyFrame (%08x) %08x\n",
(int) pRLWinPriv, (int) pRLWinPriv->hWnd);
@ -401,11 +407,40 @@ winMWExtWMDestroyFrame (RootlessFrameID wid)
#endif
#endif
/* Store the info we need to destroy after this window is gone */
hInstance = (HINSTANCE) GetClassLong (pRLWinPriv->hWnd, GCL_HMODULE);
hiconClass = (HICON) GetClassLong (pRLWinPriv->hWnd, GCL_HICON);
iReturn = GetClassName (pRLWinPriv->hWnd, pszClass, 512);
pRLWinPriv->fClose = TRUE;
pRLWinPriv->fDestroyed = TRUE;
/* Destroy the Windows window */
DestroyWindow (pRLWinPriv->hWnd);
/* Only if we were able to get the name */
if (iReturn)
{
#if CYGMULTIWINDOW_DEBUG
ErrorF ("winDestroyWindowsWindow - Unregistering %s: ", pszClass);
#endif
iReturn = UnregisterClass (pszClass, hInstance);
#if CYGMULTIWINDOW_DEBUG
ErrorF ("winDestroyWindowsWindow - %d Deleting Icon: ", iReturn);
#endif
/* Only delete if it's not the default */
if (hiconClass != g_hiconX &&
!winIconIsOverride((unsigned long)hiconClass))
{
iReturn = DestroyIcon (hiconClass);
#if CYGMULTIWINDOW_DEBUG
ErrorF ("winDestroyWindowsWindow - %d\n", iReturn);
#endif
}
}
#if CYGMULTIWINDOW_DEBUG
ErrorF ("winMWExtWMDestroyFrame - done\n");
#endif
@ -779,7 +814,7 @@ winMWExtWMStartDrawing (RootlessFrameID wid, char **pixelData, int *bytesPerRow)
}
else
{
ErrorF ("winMWExtWMStartDrawing - Already window was destoroyed \n");
ErrorF ("winMWExtWMStartDrawing - Already window was destroyed \n");
}
#if CYGMULTIWINDOW_DEBUG
ErrorF ("winMWExtWMStartDrawing - done (0x08x) 0x%08x %d\n",

View file

@ -479,11 +479,15 @@ winMWExtWMWindowProc (HWND hwnd, UINT message,
/* Free the screen DC */
ReleaseDC (pRLWinPriv->hWnd, pRLWinPriv->hdcScreen);
pRLWinPriv->hdcScreen = NULL;
/* Free shadow buffer info header */
free (pRLWinPriv->pbmihShadow);
pRLWinPriv->pbmihShadow = NULL;
pRLWinPriv->fResized = FALSE;
pRLWinPriv->pfb = NULL;
free (pRLWinPriv);
SetProp (hwnd, WIN_WINDOW_PROP, (HANDLE)NULL);
RemoveProp (hwnd, WIN_WINDOW_PROP);
break;
case WM_MOUSEMOVE: