public inbox for sourcenav@sourceware.org
 help / color / mirror / Atom feed
* Patch to get rid of error when closing last window
@ 2002-02-12 16:49 Mo DeJong
  2002-02-12 17:15 ` Ian Roxborough
  2002-02-19 20:27 ` Mo DeJong
  0 siblings, 2 replies; 5+ messages in thread
From: Mo DeJong @ 2002-02-12 16:49 UTC (permalink / raw)
  To: sourcenav

If you are using the CVS version of sourcenav and are running into an error
while closing the last window in a project that looks something like this:

invalid command name "::.t2"
    while executing
"::.t2 itk_component delete button"
    (in namespace inscope "::itk::Archetype" script line 1)
    invoked from within

then you will want to test out the following patch. The patch fixes
the problem but I am waiting to see what the itk maintainers think
of the patch before submitting it for inclusion in the sources itcl
module.

cheers
Mo DeJong


Index: itk/library/Toplevel.itk
===================================================================
RCS file: /cvs/src/src/itcl/itk/library/Toplevel.itk,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 Toplevel.itk
--- Toplevel.itk	2001/09/09 19:49:05	1.1.1.2
+++ Toplevel.itk	2002/02/08 22:17:17
@@ -63,6 +63,12 @@
             }
             destroy $itk_hull
         }
+        itk_component delete hull
+
+        # Any remaining components must be outside the hull
+        foreach component [component] {
+            destroy [component $component]
+        }
     }
 
     itk_option define -title title Title "" {
Index: itk/library/Widget.itk
===================================================================
RCS file: /cvs/src/src/itcl/itk/library/Widget.itk,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 Widget.itk
--- Widget.itk	2001/09/09 19:49:05	1.1.1.2
+++ Widget.itk	2002/02/08 22:17:17
@@ -64,6 +64,12 @@
             }
             destroy $itk_hull
         }
+        itk_component delete hull
+
+        # Any remaining components must be outside the hull
+        foreach component [component] {
+            destroy [component $component]
+        }
     }
 
     private variable itk_hull ""

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Patch to get rid of error when closing last window
  2002-02-12 16:49 Patch to get rid of error when closing last window Mo DeJong
@ 2002-02-12 17:15 ` Ian Roxborough
  2002-02-13  1:51   ` Mo DeJong
  2002-02-19 20:27 ` Mo DeJong
  1 sibling, 1 reply; 5+ messages in thread
From: Ian Roxborough @ 2002-02-12 17:15 UTC (permalink / raw)
  To: Mo DeJong; +Cc: sourcenav


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.

On Fri, 8 Feb 2002 14:44:12 -0800 Mo DeJong <supermo@bayarea.net> wrote:
>
> If you are using the CVS version of sourcenav and are running into an error
> while closing the last window in a project that looks something like this:
> 
> invalid command name "::.t2"
>     while executing
> "::.t2 itk_component delete button"
>     (in namespace inscope "::itk::Archetype" script line 1)
>     invoked from within
> 
> then you will want to test out the following patch. The patch fixes
> the problem but I am waiting to see what the itk maintainers think
> of the patch before submitting it for inclusion in the sources itcl
> module.
> 
> cheers
> Mo DeJong
> 
> 
> Index: itk/library/Toplevel.itk
> ===================================================================
> RCS file: /cvs/src/src/itcl/itk/library/Toplevel.itk,v
> retrieving revision 1.1.1.2
> diff -u -r1.1.1.2 Toplevel.itk
> --- Toplevel.itk	2001/09/09 19:49:05	1.1.1.2
> +++ Toplevel.itk	2002/02/08 22:17:17
> @@ -63,6 +63,12 @@
>              }
>              destroy $itk_hull
>          }
> +        itk_component delete hull
> +
> +        # Any remaining components must be outside the hull
> +        foreach component [component] {
> +            destroy [component $component]
> +        }
>      }
>  
>      itk_option define -title title Title "" {
> Index: itk/library/Widget.itk
> ===================================================================
> RCS file: /cvs/src/src/itcl/itk/library/Widget.itk,v
> retrieving revision 1.1.1.2
> diff -u -r1.1.1.2 Widget.itk
> --- Widget.itk	2001/09/09 19:49:05	1.1.1.2
> +++ Widget.itk	2002/02/08 22:17:17
> @@ -64,6 +64,12 @@
>              }
>              destroy $itk_hull
>          }
> +        itk_component delete hull
> +
> +        # Any remaining components must be outside the hull
> +        foreach component [component] {
> +            destroy [component $component]
> +        }
>      }
>  
>      private variable itk_hull ""

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Patch to get rid of error when closing last window
  2002-02-12 17:15 ` Ian Roxborough
@ 2002-02-13  1:51   ` Mo DeJong
  0 siblings, 0 replies; 5+ messages in thread
From: Mo DeJong @ 2002-02-13  1:51 UTC (permalink / raw)
  To: sourcenav

On Tue, 12 Feb 2002 16:39:29 -0800
Ian Roxborough <irox@redhat.com> 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.

cheers
Mo

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}

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Patch to get rid of error when closing last window
  2002-02-12 16:49 Patch to get rid of error when closing last window Mo DeJong
  2002-02-12 17:15 ` Ian Roxborough
@ 2002-02-19 20:27 ` Mo DeJong
  2002-02-21 20:34   ` Ian Roxborough
  1 sibling, 1 reply; 5+ messages in thread
From: Mo DeJong @ 2002-02-19 20:27 UTC (permalink / raw)
  To: insight; +Cc: sourcenav

Hi all.

Here is a patch that fixes a problem in Source-Navigator related to closing
of the last main window. The bug was caused by a problem in Itk where
a component in an Itk megawidget would not get destroyed if it was not a
child of the hull. The attached patch fixes the problem and adds test cases
to Itk for the areas that were changed.

This patch has already been submitted to the Itk maintainers at SF. Michael
McLennan's comment on the patch is as follows:

This patch looks good. If you want to apply it to CVS, you have my blessing
and my thanks.

cheers
Mo DeJong

2002-02-19  Mo DeJong  <supermo@bayarea.net>

	* itk/library/Toplevel.itk (destructor):
	* itk/library/Widget.itk (destructor): Remove the
	hull component after destroying the hull.
	Destroy any component that still exists after
	destroying the hull since it must have been
	created outside the hull.
	* itk/tests/toplevel.test:
	* itk/tests/widget.test: Test that a component
	outside the hull is destroyed when the mega-widget
	is destroyed.

Index: itk/library/Toplevel.itk
===================================================================
RCS file: /cvs/src/src/itcl/itk/library/Toplevel.itk,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 Toplevel.itk
--- Toplevel.itk	2001/09/09 19:49:05	1.1.1.2
+++ Toplevel.itk	2002/02/19 23:05:11
@@ -63,6 +63,12 @@
             }
             destroy $itk_hull
         }
+        itk_component delete hull
+
+        # Any remaining components must be outside the hull
+        foreach component [component] {
+            destroy [component $component]
+        }
     }
 
     itk_option define -title title Title "" {
Index: itk/library/Widget.itk
===================================================================
RCS file: /cvs/src/src/itcl/itk/library/Widget.itk,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 Widget.itk
--- Widget.itk	2001/09/09 19:49:05	1.1.1.2
+++ Widget.itk	2002/02/19 23:05:11
@@ -64,6 +64,12 @@
             }
             destroy $itk_hull
         }
+        itk_component delete hull
+
+        # Any remaining components must be outside the hull
+        foreach component [component] {
+            destroy [component $component]
+        }
     }
 
     private variable itk_hull ""
Index: itk/tests/toplevel.test
===================================================================
RCS file: /cvs/src/src/itcl/itk/tests/toplevel.test,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 toplevel.test
--- toplevel.test	2001/09/09 19:49:06	1.1.1.2
+++ toplevel.test	2002/02/19 23:05:11
@@ -79,6 +79,45 @@
     itcl::find objects .testToplevel*
 } {}
 
+test toplevel-1.7 {when an mega-widget object is deleted, its window and any
+        components are destroyed } {
+    TestToplevel .delme
+    set label [.delme component test1]
+    itcl::delete object .delme
+    list [winfo exists .delme] [winfo exists $label]
+} {0 0}
+
+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}
+
 # ----------------------------------------------------------------------
 #  Clean up
 # ----------------------------------------------------------------------
Index: itk/tests/widget.test
===================================================================
RCS file: /cvs/src/src/itcl/itk/tests/widget.test,v
retrieving revision 1.1.1.2
diff -u -1 -r1.1.1.2 widget.test
--- widget.test	2001/09/09 19:49:06	1.1.1.2
+++ widget.test	2002/02/19 23:06:23
@@ -267,2 +267,38 @@
 
+test widget-1.27 {when a mega-widget object is deleted, its window and any
+        components are destroyed (even if in another window) } {
+    itcl::class ButtonWidget {
+        inherit itk::Widget
+
+        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
+    frame .t1.f
+    ButtonWidget .t1.bw -container .t1.f
+
+    pack .t1.f
+    pack .t1.bw
+
+    set button [.t1.bw component button]
+
+    itcl::delete object .t1.bw
+
+    set result [list $button [winfo exists $button]]
+
+    itcl::delete class ButtonWidget
+
+    set result
+} {.t1.f.b 0}
+
+
 # ----------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Patch to get rid of error when closing last window
  2002-02-19 20:27 ` Mo DeJong
@ 2002-02-21 20:34   ` Ian Roxborough
  0 siblings, 0 replies; 5+ messages in thread
From: Ian Roxborough @ 2002-02-21 20:34 UTC (permalink / raw)
  To: Mo DeJong; +Cc: insight, sourcenav

Hi,

I've check this in.  Thanks Mo.

Ian.


Mo DeJong wrote:
> 
> Hi all.
> 
> Here is a patch that fixes a problem in Source-Navigator related to closing
> of the last main window. The bug was caused by a problem in Itk where
> a component in an Itk megawidget would not get destroyed if it was not a
> child of the hull. The attached patch fixes the problem and adds test cases
> to Itk for the areas that were changed.
> 
> This patch has already been submitted to the Itk maintainers at SF. Michael
> McLennan's comment on the patch is as follows:
> 
> This patch looks good. If you want to apply it to CVS, you have my blessing
> and my thanks.
> 
> cheers
> Mo DeJong
> 
> 2002-02-19  Mo DeJong  <supermo@bayarea.net>
> 
>         * itk/library/Toplevel.itk (destructor):
>         * itk/library/Widget.itk (destructor): Remove the
>         hull component after destroying the hull.
>         Destroy any component that still exists after
>         destroying the hull since it must have been
>         created outside the hull.
>         * itk/tests/toplevel.test:
>         * itk/tests/widget.test: Test that a component
>         outside the hull is destroyed when the mega-widget
>         is destroyed.
> 
> Index: itk/library/Toplevel.itk
> ===================================================================
> RCS file: /cvs/src/src/itcl/itk/library/Toplevel.itk,v
> retrieving revision 1.1.1.2
> diff -u -r1.1.1.2 Toplevel.itk
> --- Toplevel.itk        2001/09/09 19:49:05     1.1.1.2
> +++ Toplevel.itk        2002/02/19 23:05:11
> @@ -63,6 +63,12 @@
>              }
>              destroy $itk_hull
>          }
> +        itk_component delete hull
> +
> +        # Any remaining components must be outside the hull
> +        foreach component [component] {
> +            destroy [component $component]
> +        }
>      }
> 
>      itk_option define -title title Title "" {
> Index: itk/library/Widget.itk
> ===================================================================
> RCS file: /cvs/src/src/itcl/itk/library/Widget.itk,v
> retrieving revision 1.1.1.2
> diff -u -r1.1.1.2 Widget.itk
> --- Widget.itk  2001/09/09 19:49:05     1.1.1.2
> +++ Widget.itk  2002/02/19 23:05:11
> @@ -64,6 +64,12 @@
>              }
>              destroy $itk_hull
>          }
> +        itk_component delete hull
> +
> +        # Any remaining components must be outside the hull
> +        foreach component [component] {
> +            destroy [component $component]
> +        }
>      }
> 
>      private variable itk_hull ""
> Index: itk/tests/toplevel.test
> ===================================================================
> RCS file: /cvs/src/src/itcl/itk/tests/toplevel.test,v
> retrieving revision 1.1.1.2
> diff -u -r1.1.1.2 toplevel.test
> --- toplevel.test       2001/09/09 19:49:06     1.1.1.2
> +++ toplevel.test       2002/02/19 23:05:11
> @@ -79,6 +79,45 @@
>      itcl::find objects .testToplevel*
>  } {}
> 
> +test toplevel-1.7 {when an mega-widget object is deleted, its window and any
> +        components are destroyed } {
> +    TestToplevel .delme
> +    set label [.delme component test1]
> +    itcl::delete object .delme
> +    list [winfo exists .delme] [winfo exists $label]
> +} {0 0}
> +
> +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}
> +
>  # ----------------------------------------------------------------------
>  #  Clean up
>  # ----------------------------------------------------------------------
> Index: itk/tests/widget.test
> ===================================================================
> RCS file: /cvs/src/src/itcl/itk/tests/widget.test,v
> retrieving revision 1.1.1.2
> diff -u -1 -r1.1.1.2 widget.test
> --- widget.test 2001/09/09 19:49:06     1.1.1.2
> +++ widget.test 2002/02/19 23:06:23
> @@ -267,2 +267,38 @@
> 
> +test widget-1.27 {when a mega-widget object is deleted, its window and any
> +        components are destroyed (even if in another window) } {
> +    itcl::class ButtonWidget {
> +        inherit itk::Widget
> +
> +        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
> +    frame .t1.f
> +    ButtonWidget .t1.bw -container .t1.f
> +
> +    pack .t1.f
> +    pack .t1.bw
> +
> +    set button [.t1.bw component button]
> +
> +    itcl::delete object .t1.bw
> +
> +    set result [list $button [winfo exists $button]]
> +
> +    itcl::delete class ButtonWidget
> +
> +    set result
> +} {.t1.f.b 0}
> +
> +
>  # ----------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2002-02-22  2:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-12 16:49 Patch to get rid of error when closing last window Mo DeJong
2002-02-12 17:15 ` Ian Roxborough
2002-02-13  1:51   ` Mo DeJong
2002-02-19 20:27 ` Mo DeJong
2002-02-21 20:34   ` Ian Roxborough

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).