Modify

#1040 closed Bug (Fixed)

_ScreenCapture_Capture(): GDI object leak with cursor capture

Reported by: rover Owned by: Jpm
Milestone: 3.3.7.0 Component: Standard UDFs
Version: 3.3.0.0 Severity: None
Keywords: _ScreenCapture_Capture Cc:

Description

The returned bitmap handles from _WinAPI_GetIconInfo() are not deleted.
(only $aIcon[4] bitmask has a valid handle when used with cursor)

modified _ScreenCapture_Capture() with added error handling in attached file

Environment = 3.3.0.0 under WIN_XP/Service Pack 2 X86

#include <ScreenCapture.au3>
Global $hBitmap, $hProcess, $aGDIObjs

$hProcess = _WinAPI_GetCurrentProcess()
If @error Then $hProcess = 0xFFFFFFFF

While 1
	Sleep(50)
	$hBitmap = _ScreenCapture_Capture("", 0, 0, 400, 300, True)
	_WinAPI_DeleteObject($hBitmap)
	$aGDIObjs = DllCall("user32.dll", "int", "GetGuiResources", "hwnd", $hProcess, "int", 0)
	ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : GDI Objects = ' & $aGDIObjs[0] & @CRLF)
	If $aGDIObjs[0] > 40 Then Exit
WEnd

Attachments (1)

_ScreenCapture_Capture.au3 (4.4 KB ) - added by rover on Jun 23, 2009 at 8:48:36 PM.
_ScreenCapture_Capture() UDF with added error handling

Download all attachments as: .zip

Change History (7)

by rover, on Jun 23, 2009 at 8:48:36 PM

Attachment: _ScreenCapture_Capture.au3 added

_ScreenCapture_Capture() UDF with added error handling

comment:1 by Jpm, on Jul 3, 2009 at 10:37:10 PM

Milestone: 3.3.1.2
Owner: changed from Gary to Jpm
Resolution: Fixed
Status: newclosed

Fixed in version: 3.3.1.2

comment:2 by djbarnes@…, on Feb 1, 2010 at 11:16:03 AM

this needs to be reopened as it exists again in 3.3.4.0...

comment:3 by Valik, on Feb 1, 2010 at 7:29:50 PM

Resolution: Fixed
Status: closedreopened

comment:4 by TicketCleanup, on Feb 1, 2010 at 8:00:01 PM

Milestone: 3.3.1.2

Automatic ticket cleanup.

comment:5 by Beege, on Feb 14, 2010 at 8:05:32 PM

I'm pretty sure the problem here is that _WinAPI_GetIconInfo returns TWO bitmaps and we are only deleting ONE of them. The cursor section of the function needs to check if $aIcon[5] is valid bitmap and delete if it is. Depending on what cursor is being displayed $aIcon[5] may not alway be a valid bitmap. From the tests I've done, when the cursor is an I-beam, the bitmap will NOT be valid. Almost all other ones were valid.

	If $fCursor Then
		Local $aCursor = _WinAPI_GetCursorInfo()
		If $aCursor[1] Then
			Local $hIcon = _WinAPI_CopyIcon($aCursor[2])
			Local $aIcon = _WinAPI_GetIconInfo($hIcon)
			_WinAPI_DeleteObject($aIcon[4]); delete bitmap mask return by _WinAPI_GetIconInfo()
	---->>>>>>>>>>>>If $aIcon[5] <> 0 Then _WinAPI_DeleteObject($aIcon[5]); delete bitmap hbmColor return by _WinAPI_GetIconInfo()
			_WinAPI_DrawIcon($hCDC, $aCursor[3] - $aIcon[2] - $iLeft, $aCursor[4] - $aIcon[3] - $iTop, $hIcon)
			_WinAPI_DestroyIcon($hIcon)
		EndIf
	EndIf

comment:6 by Jpm, on Apr 20, 2010 at 11:05:51 PM

Milestone: 3.3.7.0
Resolution: Fixed
Status: reopenedclosed

Fixed by revision [5768] in version: 3.3.7.0

Modify Ticket

Action
as closed The owner will remain Jpm.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.