Opened 10 years ago

Closed 10 years ago

#2813 closed Bug (Fixed)

Accessing "last created control" once GUI deleted - AutoIt HardCrash

Reported by: mLipok Owned by: Jon
Milestone: Component: AutoIt
Version: Severity: None
Keywords: Cc:


Today I have another day cleanup of old scripts.
I changed my own UDF files.
Most scripts that use these UDF is working properly, only one showed a tendency to HardCrash.

After a few hour searching, I managed to prepare the reproductive script.
I know that he is in some sense an unusual but in the best way I know of shows where the error is.

#include <GUIConstantsEx.au3>

ConsoleWrite(@CRLF & 'Checking normal behavior' & @CRLF)

ConsoleWrite(@CRLF & 'Checking AutoIt HardCrash' & @CRLF)

Func GUI($bTest = False )
	Local $hGUI = GUICreate('TITLE', 100, 100)
	Local $idEdit = GUICtrlCreateEdit('', 1, 1, 99, 99)

	ConsoleWrite('$bTest = '&$bTest &' @ScriptLineNumber =' & @ScriptLineNumber & @CRLF)
	If $bTest = True then
		; Here you can see AutoIt HardCrash
		GUICtrlSetResizing(-1, $GUI_DOCKALL)
		GUICtrlSetResizing($idEdit, $GUI_DOCKALL)
	ConsoleWrite('$bTest = '&$bTest &' @ScriptLineNumber =' & @ScriptLineNumber & @CRLF)
EndFunc   ;==>GUI

Checked on:
AutoIt and

Attachments (0)

Change History (4)

comment:1 follow-up: Changed 10 years ago by Melba23

In fact the problem is caused by trying to reference the "last created control" once the GUI containing it has been deleted - the actual function used is irrelevant (I have amended the ticket title to reflect this). No doubt the internal reference to this control has been deleted along with the GUI.

I would argue that using the "-1" shorthand should be avoided wherever possible - which would render the problem moot - and that trying to access controls once the GUI holding them has been deleted is not something that should be done either. But worth a look to see if there is a simple check which would prevent the crash.


comment:2 Changed 10 years ago by Melba23

  • Summary changed from GUICtrlSetResizing(-1, - last created control - AutoIt HardCrash to Accessing "last created control" once GUI deleted - AutoIt HardCrash

comment:3 in reply to: ↑ 1 Changed 10 years ago by mLipok

Replying to Melba23:

the actual function used is irrelevant

Yes you have right, but in my script this was not intentional, just a mistake, in a process of massive change.

So I describe what happend to me.
I have Gui wrappers like this:


and my main gui lets call them:

I can add TabItem to existing GUI_FRAMEWORK

So some controls was created and deleted when _GUI_Question() was called , to ask user for config option when my program starts, and then I missed to initialize _GUI_FRAMEWORK_INIT() before I add new TabItem (I change the place where GUI_FRAMEWORK is initialized).

Actually I'm making a massive change in my old (but working and still developed) scripts. So that issue, just happens.

comment:4 Changed 10 years ago by Jon

  • Milestone set to
  • Owner set to Jon
  • Resolution set to Fixed
  • Status changed from new to closed

Fixed by revision [10489] in version:

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

as closed The owner will remain Jon.

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

Note: See TracTickets for help on using tickets.