Modify

Opened 15 years ago

Closed 14 years ago

#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 15 years ago.
_ScreenCapture_Capture() UDF with added error handling

Download all attachments as: .zip

Change History (7)

Changed 15 years ago by rover

_ScreenCapture_Capture() UDF with added error handling

comment:1 Changed 15 years ago by Jpm

  • Milestone set to 3.3.1.2
  • Owner changed from Gary to Jpm
  • Resolution set to Fixed
  • Status changed from new to closed

Fixed in version: 3.3.1.2

comment:2 Changed 14 years ago by djbarnes@…

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

comment:3 Changed 14 years ago by Valik

  • Resolution Fixed deleted
  • Status changed from closed to reopened

comment:4 Changed 14 years ago by TicketCleanup

  • Milestone 3.3.1.2 deleted

Automatic ticket cleanup.

comment:5 Changed 14 years ago by Beege

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 Changed 14 years ago by Jpm

  • Milestone set to 3.3.7.0
  • Resolution set to Fixed
  • Status changed from reopened to closed

Fixed by revision [5768] in version: 3.3.7.0

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The owner will remain Jpm.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.