public inbox for insight@sourceware.org
 help / color / mirror / Atom feed
* Re: Patch to get rid of error when closing last window
       [not found] <20020208144412.288bb411.supermo@bayarea.net>
@ 2002-02-19 15:19 ` Mo DeJong
  2002-02-21 18:35   ` Ian Roxborough
  0 siblings, 1 reply; 2+ messages in thread
From: Mo DeJong @ 2002-02-19 15:19 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] 2+ messages in thread

* Re: Patch to get rid of error when closing last window
  2002-02-19 15:19 ` Patch to get rid of error when closing last window Mo DeJong
@ 2002-02-21 18:35   ` Ian Roxborough
  0 siblings, 0 replies; 2+ messages in thread
From: Ian Roxborough @ 2002-02-21 18:35 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] 2+ messages in thread

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

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20020208144412.288bb411.supermo@bayarea.net>
2002-02-19 15:19 ` Patch to get rid of error when closing last window Mo DeJong
2002-02-21 18:35   ` 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).