Re: Gtk::manage



On Tue, 2005-07-19 at 21:57 +0200, Antonio Coralles wrote:
> I did not use Gtk::manage(...) until now. However, i knew it was there,
> and today i thought it could come in very handy in a particular coding
> task. What i do, stripped to the bare minimum is this:  I have a  two
> classes, basically of type Gtk::Bin, call them  Bin1 (a Gtk::Frame),
> Bin2 (derived from Gtk::ScrolledWindow) and a method of another class,
> lets say 'void AnotherClass ::something()'.
> 
> void AnotherClass::something()
> {
>        Bin1* p_bin1 = getBin1();
>        p_bin1->remove();
>       
>        Bin2* p_bin2 = Gtk::manage(new Bin2);
>        p_bin1->add(*p_bin2);
> }
> 
> I thought that through calling p_bin1->remove(), the old object, stored
> in p_bin1 should be deleted.

No, remove() is not meant to delete your object. That would be awkard if
you wanted to just remove() it before adding() it somewhere else. Use
delete to delete.

>  However, as my 'Bin2 class' allocates about
> 3MB, i can see clearly in the system monitor, that this doesn't happen.
> 
> You might guess, that my destructor for Bin2 is not virtual - but this
> is not true. Besides, i was able to stuff this leak by switching to my
> own memory management, which was, thanks to boost::scoped_array and
> boost::scoped_ptr not that difficult.
> 
> So may question is: Did i try somthing which was not intended with
> Gtk::manage, or did i discover a bug ?
> 
> I'm using gtkmm-2.6.3.
> Antonio
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
-- 
Murray Cumming
murrayc murrayc com
www.murrayc.com
www.openismus.com




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]