Fix GDI handle leaks

svn path=/trunk/; revision=4425
This commit is contained in:
Gé van Geldorp 2003-03-24 22:49:54 +00:00
parent a3437854ba
commit 0d5ed410c1
4 changed files with 40 additions and 29 deletions

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: mouse.c,v 1.20 2003/03/11 00:21:41 gvg Exp $
/* $Id: mouse.c,v 1.21 2003/03/24 22:49:54 gvg Exp $
*
* PROJECT: ReactOS kernel
* PURPOSE: Mouse
@ -320,37 +320,41 @@ EnableMouse(HDC hDisplayDC)
SIZEL MouseSize;
RECTL MouseRect;
dc = DC_HandleToPtr(hDisplayDC);
if( dc ){
SurfObj = (PSURFOBJ)AccessUserObject((ULONG) dc->Surface);
SurfGDI = (PSURFGDI)AccessInternalObject((ULONG) dc->Surface);
DC_ReleasePtr( hDisplayDC );
if( hDisplayDC )
{
dc = DC_HandleToPtr(hDisplayDC);
SurfObj = (PSURFOBJ)AccessUserObject((ULONG) dc->Surface);
SurfGDI = (PSURFGDI)AccessInternalObject((ULONG) dc->Surface);
DC_ReleasePtr( hDisplayDC );
/* Create the default mouse cursor. */
mouse_width = 32;
mouse_height = 32;
MouseSize.cx = 32;
MouseSize.cy = 64;
hMouseSurf = EngCreateBitmap(MouseSize, 4, BMF_1BPP, BMF_TOPDOWN, DefaultCursor);
MouseSurf = (PSURFOBJ)AccessUserObject((ULONG) hMouseSurf);
/* Create the default mouse cursor. */
mouse_width = 32;
mouse_height = 32;
MouseSize.cx = 32;
MouseSize.cy = 64;
hMouseSurf = EngCreateBitmap(MouseSize, 4, BMF_1BPP, BMF_TOPDOWN, DefaultCursor);
MouseSurf = (PSURFOBJ)AccessUserObject((ULONG) hMouseSurf);
/* Tell the display driver to set the pointer shape. */
/* Tell the display driver to set the pointer shape. */
#if 0
mouse_x = SurfObj->sizlBitmap.cx / 2;
mouse_y = SurfObj->sizlBitmap.cy / 2;
mouse_x = SurfObj->sizlBitmap.cx / 2;
mouse_y = SurfObj->sizlBitmap.cy / 2;
#else
mouse_x = 320;
mouse_y = 240;
mouse_x = 320;
mouse_y = 240;
#endif
PointerStatus = SurfGDI->SetPointerShape(SurfObj, MouseSurf, NULL, NULL,
0, 0, mouse_x, mouse_y, &MouseRect,
SPS_CHANGE);
PointerStatus = SurfGDI->SetPointerShape(SurfObj, MouseSurf, NULL, NULL,
0, 0, mouse_x, mouse_y, &MouseRect,
SPS_CHANGE);
MouseEnabled = (SPS_ACCEPT_EXCLUDE == PointerStatus ||
SPS_ACCEPT_NOEXCLUDE == PointerStatus);
MouseEnabled = (SPS_ACCEPT_EXCLUDE == PointerStatus ||
SPS_ACCEPT_NOEXCLUDE == PointerStatus);
EngDeleteSurface(hMouseSurf);
}
else{
MouseEnabled = FALSE;
else
{
MouseEnabled = FALSE;
}
}

View file

@ -27,7 +27,7 @@ BOOL STDCALL W32kBitBlt(HDC hDCDest,
POINTL SourcePoint;
PBITMAPOBJ DestBitmapObj;
PBITMAPOBJ SrcBitmapObj;
BOOL Status, SurfDestAlloc, SurfSrcAlloc;
BOOL Status, SurfDestAlloc, SurfSrcAlloc, XlateAlloc;
PPALOBJ DCLogPal;
PPALGDI PalDestGDI, PalSourceGDI;
PXLATEOBJ XlateObj = NULL;
@ -49,6 +49,7 @@ BOOL STDCALL W32kBitBlt(HDC hDCDest,
SurfDestAlloc = FALSE;
SurfSrcAlloc = FALSE;
XlateAlloc = FALSE;
// Determine surfaces to be used in the bitblt
SurfDest = (PSURFOBJ)AccessUserObject(DCDest->Surface);
@ -83,14 +84,16 @@ BOOL STDCALL W32kBitBlt(HDC hDCDest,
PalSourceGDI = (PPALGDI)AccessInternalObject(SourcePalette);
XlateObj = (PXLATEOBJ)IntEngCreateXlate(PalDestGDI->Mode, PalSourceGDI->Mode, DestPalette, SourcePalette);
XlateAlloc = TRUE;
}
// Perform the bitblt operation
Status = IntEngBitBlt(SurfDest, SurfSrc, NULL, NULL, XlateObj, &DestRect, &SourcePoint, NULL, NULL, NULL, ROP);
if(SurfDestAlloc == TRUE) ExFreePool(SurfDest);
if(SurfSrcAlloc == TRUE) ExFreePool(SurfSrc);
if (XlateAlloc) EngDeleteXlate(XlateObj);
if (SurfDestAlloc) ExFreePool(SurfDest);
if (SurfSrcAlloc) ExFreePool(SurfSrc);
DC_ReleasePtr(hDCDest);
DC_ReleasePtr(hDCSrc);

View file

@ -1,4 +1,4 @@
/* $Id: dc.c,v 1.51 2003/03/22 23:57:32 gvg Exp $
/* $Id: dc.c,v 1.52 2003/03/24 22:49:54 gvg Exp $
*
* DC.C - Device context functions
*
@ -497,6 +497,7 @@ BOOL STDCALL W32kDeleteDC(HDC DCHandle)
BITMAPOBJ_ReleasePtr(DCToDelete->w.hBitmap);
if (DCToDelete->w.flags & DC_MEMORY)
{
EngDeleteSurface (DCToDelete->Surface);
W32kDeleteObject (DCToDelete->w.hFirstBitmap);
}
}
@ -1082,6 +1083,7 @@ HGDIOBJ STDCALL W32kSelectObject(HDC hDC, HGDIOBJ hGDIObj)
objOrg = (HGDIOBJ)dc->w.hBitmap;
/* Release the old bitmap, lock the new one and convert it to a SURF */
EngDeleteSurface(dc->Surface);
BITMAPOBJ_ReleasePtr(objOrg);
dc->w.hBitmap = hGDIObj;
pb = BITMAPOBJ_HandleToPtr(hGDIObj);

View file

@ -154,6 +154,8 @@ INT STDCALL W32kSetDIBits(HDC hDC,
}
// Clean up
EngDeleteXlate(XlateObj);
EngDeletePalette(DIB_Palette);
EngDeleteSurface(SourceBitmap);
EngDeleteSurface(DestBitmap);