Modify

Opened 17 years ago

Closed 16 years ago

#1040 closed Bug (Fixed)

_ScreenCapture_Capture(): GDI object leak with cursor capture

Reported by: rover Owned by: J-Paul Mesnage
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 17 years ago.
_ScreenCapture_Capture() UDF with added error handling

Download all attachments as: .zip

Change History (7)

by rover, 17 years ago

Attachment: _ScreenCapture_Capture.au3 added

_ScreenCapture_Capture() UDF with added error handling

comment:1 by J-Paul Mesnage, 17 years ago

Milestone: 3.3.1.2
Owner: changed from Gary to J-Paul Mesnage
Resolution: Fixed
Status: newclosed

Fixed in version: 3.3.1.2

comment:2 by djbarnes@…, 16 years ago

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

comment:3 by Valik, 16 years ago

Resolution: Fixed
Status: closedreopened

comment:4 by TicketCleanup, 16 years ago

Milestone: 3.3.1.2

Automatic ticket cleanup.

comment:5 by Beege, 16 years ago

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 J-Paul Mesnage, 16 years ago

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 J-Paul Mesnage.

Add Comment


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