Modify

Opened 16 months ago

Last modified 3 days ago

#4026 new Bug

COM Object/Map/ScriptingDictionary crash when acessing them in specific ways.

Reported by: anonymous Owned by:
Milestone: Component: AutoIt
Version: 3.3.16.1 Severity: None
Keywords: Cc:

Description

it's a rather rare teeny-tiny bug, and there's an easy workaround... still...

Reproducer:

$inp = InputBox('choice', 'test Object(1), Map(2), or ScriptingDictionary(3)?', '1')
if @error then exit
if $inp = 1 then ; -- COM object -- 
#Illegal text at the end of statement (one statement per line).
        Run("notepad.exe")
        $hNotepad = WinWait("[CLASS:Notepad]")
        $answer = MsgBox(0x24,'...', 'Delete notepad icon from taskbar?')
        if $answer=6 then TaskbarListObj().DeleteTab($hNotepad) ;crashes -- "Illegal text at the end of statement (one statement per line)."
;~      if $answer=6 then (TaskbarListObj().DeleteTab($hNotepad)) ; a workaround that works

elseif $inp = 2 then ; -- Map --
#The requested action with this object has failed.
        $m = Map()
        ConsoleWrite("$m.greet's type:"&VarGetType($m.greet) & @CRLF)
        $m.greet() ; - crashes: "The requested action with this object has failed."

else  ; -- ScriptingDictionary -- 
#Illegal text at the end of statement (one statement per line).
        ((Dict())('fn'))(1) ; works
        (Dict())('fn')(2) ; doesnt, yet no crash, no error, no nothing...
        (Dict()('fn'))(3) ; works
        Dict()('fn')(4) ; crashes

EndIf

Func TaskbarListObj()
        Local $sCLSID_TaskbarList = "{56FDF344-FD6D-11D0-958A-006097C9A090}"
        Local $sIID_ITaskbarList = "{56FDF342-FD6D-11D0-958A-006097C9A090}"
        Local $sTagITaskbarList = "HrInit hresult(); AddTab hresult(hwnd); DeleteTab hresult(hwnd); ActivateTab hresult(hwnd); SetActiveAlt hresult(hwnd);"
        Local $oTaskbarList = ObjCreateInterface($sCLSID_TaskbarList, $sIID_ITaskbarList, $sTagITaskbarList)
        $oTaskbarList.HrInit()
        Return $oTaskbarList
EndFunc
Func Map()
        Local $m[]
        $m.greet = sayhi
        Return $m
EndFunc
Func sayhi()
        MsgBox(0x40,'welp','...hi....')
EndFunc
Func Dict()
        Local $d = ObjCreate('Scripting.Dictionary')
        $d('fn') = sayhey
        Return $d
EndFunc
Func sayhey($n)
        ConsoleWrite(' \ o/ heeeey ' &$n& @CRLF)
EndFunc

Attachments (0)

Change History (1)

comment:1 Changed 3 weeks ago by Jpm

I don't know if we can do something about the order of evaluation
The parenthesis take care of the evaluation in the correct order

Due this complexity the AutoIt checking is wrong. I am almost sure we cannot get it to follow the evaluation of com object.
so AutoItCheck must be bypass in such occasion
here is the example annotated

#AutoIt3Wrapper_Run_Au3Check= n

#include <MsgBoxConstants.au3>

Local $inp = InputBox('choice', 'test Object(1), Map(2), or ScriptingDictionary(3)?', '1')
If @error Then Exit
If $inp = 1 Then ; -- COM object --
        ;#Illegal text at the end of statement (one statement per line).
        Run("notepad.exe")
        Local $hNotepad = WinWait("[CLASS:Notepad]")
        Local $answer = MsgBox($MB_ICONQUESTION + $MB_YESNO, '...', 'Delete notepad icon from taskbar?')
;~      If $answer = $IDYES Then TaskbarListObj().DeleteTab($hNotepad)   ; Fatal Error : "Illegal text at the end of statement (one statement per line)."
        If $answer = $IDYES Then (TaskbarListObj()).DeleteTab($hNotepad) ; a workaround that works to have the evaluation <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        ; Tell the user to look again.
        MsgBox($MB_ICONINFORMATION, "", "Look in the Taskbar.  There should no longer be a Notepad entry but Notepad is still running." & @CRLF & @CRLF & "Press OK to continue.")
        ; Close Notepad.
        WinClose($hNotepad)

ElseIf $inp = 2 Then ; -- Map --
        ;#The requested action with this object has failed.
        Local $m = Map()
        ConsoleWrite("$m.greet's type:" & VarGetType($m.greet) & @CRLF)
        ($m.greet) ()  ; works as the evaluation is done before calling <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        $m.greet()     ; Fatal Error : "The requested action with this object has failed."

Else  ; -- ScriptingDictionary --
        ;#Illegal text at the end of statement (one statement per line).
        ((Dict()) ('fn')) (1) ; works as the evaluation is done before calling <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        (Dict()) ('fn') (2)   ; doesnt, yet no crash, no error, no nothing...
        (Dict() ('fn')) (3)   ; works as the evaluation is done before calling <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        Dict() ('fn') (4)     ; Fatal Error : "Illegal text at the end of statement (one statement per line)."

EndIf

Func TaskbarListObj()
        Local $sCLSID_TaskbarList = "{56FDF344-FD6D-11D0-958A-006097C9A090}"
        Local $sIID_ITaskbarList = "{56FDF342-FD6D-11D0-958A-006097C9A090}"
        Local $sTagITaskbarList = "HrInit hresult(); AddTab hresult(hwnd); DeleteTab hresult(hwnd); ActivateTab hresult(hwnd); SetActiveAlt hresult(hwnd);"
        Local $oTaskbarList = ObjCreateInterface($sCLSID_TaskbarList, $sIID_ITaskbarList, $sTagITaskbarList)
        $oTaskbarList.HrInit()

        Return $oTaskbarList
EndFunc   ;==>TaskbarListObj

Func Map()
        Local $m[]
        $m.greet = sayhi

        Return $m
EndFunc   ;==>Map

Func sayhi()
        MsgBox($MB_ICONINFORMATION, 'welp', '...hi....')
EndFunc   ;==>sayhi

Func Dict()
        Local $d = ObjCreate('Scripting.Dictionary')
        $d('fn') = sayhey

        Return $d
EndFunc   ;==>Dict

Func sayhey($n)
        ConsoleWrite(' \ o/ heeeey ' & $n & @CRLF)
EndFunc   ;==>sayhey

Last edited 3 days ago by mLipok (previous) (diff)

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 new The ticket will remain with no owner.
Author


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

 
Note: See TracTickets for help on using tickets.