Skip to content

"Error: Gui has no window" when debug adapter evaluates a destroyed Gui object #317

@SAbboushi

Description

@SAbboushi

It seems MyGui.Destroy()

leaves behind a useless Gui object in the MyGui variable https://www.autohotkey.com/boards/viewtopic.php?style=19&t=108635#p483346

I suspect this is what causes the debug adapter to throw "Error: Gui has no window" if/when it tries to evaluate the "destroyed" Gui object when e.g. the Gui object's variable name is visible in the VARIABLES pane (I note that MyGui.base.Hwnd shows as "<error>").

I find this makes it very difficult to debug the script because the error continually displays at breakpoints.

Anything you can do to overcome this problem? My thoughts:

  • Although I can't think of one, I wonder if there are times when a programming error results in a GUI-object-without-a-window in which case this error message would be useful? In which case, I suspect trying to overcome this problem in the debugger adapter would be expensive...

  • I wonder why the Destroy() method

    leaves behind a useless Gui object in the MyGui variable

    which I suspect is the cause of this problem I'm trying to overcome?

  • So far, it seems Lexicos' suggestion to [set MyGui := ""] would prevent this problem when debugging... which would require changing my scripts... which again makes me wonder why the Destroy() method doesn't do that?

Any thoughts?

To reproduce, single step through code and expand "Global" in the VARIABLES pane before executing MyGui.Destroy():

MyGui := Gui()
MyGui.Show("w500 h50")
MyGui.Destroy()

x := 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions