From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10797 invoked by alias); 22 Feb 2002 02:35:15 -0000 Mailing-List: contact sourcenav-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: sourcenav-owner@sources.redhat.com Received: (qmail 10570 invoked from network); 22 Feb 2002 02:35:05 -0000 Received: from unknown (HELO cygnus.com) (205.180.230.5) by sources.redhat.com with SMTP; 22 Feb 2002 02:35:05 -0000 Received: from redhat.com (cse.cygnus.com [205.180.230.236]) by runyon.cygnus.com (8.8.7-cygnus/8.8.7) with ESMTP id SAA04012; Thu, 21 Feb 2002 18:35:00 -0800 (PST) Message-ID: <3C75BFE5.20102E28@redhat.com> Date: Thu, 21 Feb 2002 20:34:00 -0000 From: Ian Roxborough X-Mailer: Mozilla 4.61 [en] (X11; I; Linux 2.2.14 i686) X-Accept-Language: en MIME-Version: 1.0 To: Mo DeJong CC: insight@sources.redhat.com, sourcenav@sources.redhat.com Subject: Re: Patch to get rid of error when closing last window References: <20020208144412.288bb411.supermo@bayarea.net> <20020219151830.7598809d.supermo@bayarea.net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-SW-Source: 2002-q1/txt/msg00106.txt.bz2 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 > > * 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} > + > + > # ----------------------------------------------------------------------