mirror of
https://github.com/reactos/reactos.git
synced 2025-04-19 12:08:55 +00:00
Fix GDI handle leaks
svn path=/trunk/; revision=4425
This commit is contained in:
parent
a3437854ba
commit
0d5ed410c1
4 changed files with 40 additions and 29 deletions
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* 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
|
* PROJECT: ReactOS kernel
|
||||||
* PURPOSE: Mouse
|
* PURPOSE: Mouse
|
||||||
|
@ -320,8 +320,9 @@ EnableMouse(HDC hDisplayDC)
|
||||||
SIZEL MouseSize;
|
SIZEL MouseSize;
|
||||||
RECTL MouseRect;
|
RECTL MouseRect;
|
||||||
|
|
||||||
|
if( hDisplayDC )
|
||||||
|
{
|
||||||
dc = DC_HandleToPtr(hDisplayDC);
|
dc = DC_HandleToPtr(hDisplayDC);
|
||||||
if( dc ){
|
|
||||||
SurfObj = (PSURFOBJ)AccessUserObject((ULONG) dc->Surface);
|
SurfObj = (PSURFOBJ)AccessUserObject((ULONG) dc->Surface);
|
||||||
SurfGDI = (PSURFGDI)AccessInternalObject((ULONG) dc->Surface);
|
SurfGDI = (PSURFGDI)AccessInternalObject((ULONG) dc->Surface);
|
||||||
DC_ReleasePtr( hDisplayDC );
|
DC_ReleasePtr( hDisplayDC );
|
||||||
|
@ -348,8 +349,11 @@ EnableMouse(HDC hDisplayDC)
|
||||||
|
|
||||||
MouseEnabled = (SPS_ACCEPT_EXCLUDE == PointerStatus ||
|
MouseEnabled = (SPS_ACCEPT_EXCLUDE == PointerStatus ||
|
||||||
SPS_ACCEPT_NOEXCLUDE == PointerStatus);
|
SPS_ACCEPT_NOEXCLUDE == PointerStatus);
|
||||||
|
|
||||||
|
EngDeleteSurface(hMouseSurf);
|
||||||
}
|
}
|
||||||
else{
|
else
|
||||||
|
{
|
||||||
MouseEnabled = FALSE;
|
MouseEnabled = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ BOOL STDCALL W32kBitBlt(HDC hDCDest,
|
||||||
POINTL SourcePoint;
|
POINTL SourcePoint;
|
||||||
PBITMAPOBJ DestBitmapObj;
|
PBITMAPOBJ DestBitmapObj;
|
||||||
PBITMAPOBJ SrcBitmapObj;
|
PBITMAPOBJ SrcBitmapObj;
|
||||||
BOOL Status, SurfDestAlloc, SurfSrcAlloc;
|
BOOL Status, SurfDestAlloc, SurfSrcAlloc, XlateAlloc;
|
||||||
PPALOBJ DCLogPal;
|
PPALOBJ DCLogPal;
|
||||||
PPALGDI PalDestGDI, PalSourceGDI;
|
PPALGDI PalDestGDI, PalSourceGDI;
|
||||||
PXLATEOBJ XlateObj = NULL;
|
PXLATEOBJ XlateObj = NULL;
|
||||||
|
@ -49,6 +49,7 @@ BOOL STDCALL W32kBitBlt(HDC hDCDest,
|
||||||
|
|
||||||
SurfDestAlloc = FALSE;
|
SurfDestAlloc = FALSE;
|
||||||
SurfSrcAlloc = FALSE;
|
SurfSrcAlloc = FALSE;
|
||||||
|
XlateAlloc = FALSE;
|
||||||
|
|
||||||
// Determine surfaces to be used in the bitblt
|
// Determine surfaces to be used in the bitblt
|
||||||
SurfDest = (PSURFOBJ)AccessUserObject(DCDest->Surface);
|
SurfDest = (PSURFOBJ)AccessUserObject(DCDest->Surface);
|
||||||
|
@ -83,14 +84,16 @@ BOOL STDCALL W32kBitBlt(HDC hDCDest,
|
||||||
PalSourceGDI = (PPALGDI)AccessInternalObject(SourcePalette);
|
PalSourceGDI = (PPALGDI)AccessInternalObject(SourcePalette);
|
||||||
|
|
||||||
XlateObj = (PXLATEOBJ)IntEngCreateXlate(PalDestGDI->Mode, PalSourceGDI->Mode, DestPalette, SourcePalette);
|
XlateObj = (PXLATEOBJ)IntEngCreateXlate(PalDestGDI->Mode, PalSourceGDI->Mode, DestPalette, SourcePalette);
|
||||||
|
XlateAlloc = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Perform the bitblt operation
|
// Perform the bitblt operation
|
||||||
|
|
||||||
Status = IntEngBitBlt(SurfDest, SurfSrc, NULL, NULL, XlateObj, &DestRect, &SourcePoint, NULL, NULL, NULL, ROP);
|
Status = IntEngBitBlt(SurfDest, SurfSrc, NULL, NULL, XlateObj, &DestRect, &SourcePoint, NULL, NULL, NULL, ROP);
|
||||||
|
|
||||||
if(SurfDestAlloc == TRUE) ExFreePool(SurfDest);
|
if (XlateAlloc) EngDeleteXlate(XlateObj);
|
||||||
if(SurfSrcAlloc == TRUE) ExFreePool(SurfSrc);
|
if (SurfDestAlloc) ExFreePool(SurfDest);
|
||||||
|
if (SurfSrcAlloc) ExFreePool(SurfSrc);
|
||||||
|
|
||||||
DC_ReleasePtr(hDCDest);
|
DC_ReleasePtr(hDCDest);
|
||||||
DC_ReleasePtr(hDCSrc);
|
DC_ReleasePtr(hDCSrc);
|
||||||
|
|
|
@ -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
|
* DC.C - Device context functions
|
||||||
*
|
*
|
||||||
|
@ -497,6 +497,7 @@ BOOL STDCALL W32kDeleteDC(HDC DCHandle)
|
||||||
BITMAPOBJ_ReleasePtr(DCToDelete->w.hBitmap);
|
BITMAPOBJ_ReleasePtr(DCToDelete->w.hBitmap);
|
||||||
if (DCToDelete->w.flags & DC_MEMORY)
|
if (DCToDelete->w.flags & DC_MEMORY)
|
||||||
{
|
{
|
||||||
|
EngDeleteSurface (DCToDelete->Surface);
|
||||||
W32kDeleteObject (DCToDelete->w.hFirstBitmap);
|
W32kDeleteObject (DCToDelete->w.hFirstBitmap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1082,6 +1083,7 @@ HGDIOBJ STDCALL W32kSelectObject(HDC hDC, HGDIOBJ hGDIObj)
|
||||||
objOrg = (HGDIOBJ)dc->w.hBitmap;
|
objOrg = (HGDIOBJ)dc->w.hBitmap;
|
||||||
|
|
||||||
/* Release the old bitmap, lock the new one and convert it to a SURF */
|
/* Release the old bitmap, lock the new one and convert it to a SURF */
|
||||||
|
EngDeleteSurface(dc->Surface);
|
||||||
BITMAPOBJ_ReleasePtr(objOrg);
|
BITMAPOBJ_ReleasePtr(objOrg);
|
||||||
dc->w.hBitmap = hGDIObj;
|
dc->w.hBitmap = hGDIObj;
|
||||||
pb = BITMAPOBJ_HandleToPtr(hGDIObj);
|
pb = BITMAPOBJ_HandleToPtr(hGDIObj);
|
||||||
|
|
|
@ -154,6 +154,8 @@ INT STDCALL W32kSetDIBits(HDC hDC,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean up
|
// Clean up
|
||||||
|
EngDeleteXlate(XlateObj);
|
||||||
|
EngDeletePalette(DIB_Palette);
|
||||||
EngDeleteSurface(SourceBitmap);
|
EngDeleteSurface(SourceBitmap);
|
||||||
EngDeleteSurface(DestBitmap);
|
EngDeleteSurface(DestBitmap);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue