Patch to get rid of error when closing last window

Mo DeJong
Wed Feb 13 01:51:00 GMT 2002

On Tue, 12 Feb 2002 16:39:29 -0800
Ian Roxborough <> wrote:

> Thanks for the other patches, Mo.
> I'm having trouble reproducing the error, I'm
> assuming the there is some dialog or window some
> where that needs to be openned or something to
> cause the problem error on exit, but I can't
> seem to trigger it.
> Ian.

All you should need to do is have a single tools window open
and then close it via the window manager. The tool window
must be the very last window on the screen, if you also have
a symbol browser open it will not be triggered. It happens
when the windows_close method in multiview.tcl sees only
one window and calls file_close_project. Also, this only
happens with the CVS version of itk in sources so if you
are building with an older release branch it will not show up.

An even more simple test case for the itk::Toplevel class
is included below. Before the patch, this test will fail
because the button put into the external -container
window would not get deleted when the megawidget
is destroyed.


test toplevel-1.8 {when a mega-widget object is deleted, its window and any
        components are destroyed (even if in another window) } {
    itcl::class ButtonTop {
        inherit itk::Toplevel

        constructor {args} {
            eval itk_initialize $args

	    itk_component add button {
                button $itk_option(-container).b -text Button
	    } {}
            pack $itk_component(button)

        itk_option define -container container Container {}

    toplevel .t1
    ButtonTop .t2 -container .t1

    set button [.t2 component button]
    itcl::delete object .t2
    set result [list $button [winfo exists $button]]
    itcl::delete class ButtonTop
    set result
} {.t1.b 0}

More information about the Sourcenav mailing list