Modify

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: 3.3.13.11 Component: AutoIt
Version: 3.3.13.10 Severity: None
Keywords: Cc:

Description

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)
GUI()

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

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

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

Checked on:
AutoIt 3.3.10.2 and 3.3.13.10

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.

M23

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:

_GUI_Question($sQuestion)
_GUI_Info('$sMessage')

and my main gui lets call them:
_GUI_FRAMEWORK_INIT()

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 3.3.13.11
  • Owner set to Jon
  • Resolution set to Fixed
  • Status changed from new to closed

Fixed by revision [10489] in version: 3.3.13.11

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 Jon.
Author


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

 
Note: See TracTickets for help on using tickets.