[gtkmm] Gtk::Container::remove and a question
- From: Robin <robin bourianes free fr>
- To: gtkmm-list gnome org
- Subject: [gtkmm] Gtk::Container::remove and a question
- Date: Sun, 17 Oct 2004 13:30:32 +0200
Hi,
I have noticed something odd (IMO) in the remove method of Gtk::Container.
When a managed widget is removed from a Gtk::Container, the remove
method adds a reference to it, and the result is that the widget is not
deleted. The programmer have to call my_widget->unreference () after the
remove call to delete it.
I thought that the fact to set a widget "Gtk managed" means that it
would be deleted by gtk when necessary. There is a comment in the remove
method explaining that the reference is here to prevent deleting the
widget in case the widget will be added to another Gtk::Container.
IMO, when a widget is set managed, this reference shouldn't be added
because if the programmer wants to remove the widget and then add it to
another container, _he_ has to put calls to reference () and unreference
() around the operation.
When I used the remove method, due to the fact i had set my widget
managed, I was expecting the widget to be deleted.
/* pseudo code */
Gtk::Widget* widget = new Gtk::Widget ();
widget->set_manage ();
.....
widget->reference ();
container1->remove (*widget);
container2->add (*widget);
widget->unreference ();
...
/* pseudo code */
My other question is more a c++ related question but I can't figure it
out ...
In fact, the example of custom container found in the gtkmm tutorial
(http://www.gtkmm.org/docs/gtkmm-2.4/docs/tutorial/html/ch21.html#id2749211)
doesn't compile on my box.
It fails with this :
/usr/include/gtkmm-2.4/gtkmm/widget.h: In member function « virtual void
MyContainer::set_child_widgets(Gtk::Widget&, Gtk::Widget&) »:
/usr/include/gtkmm-2.4/gtkmm/widget.h:2434: error: `void
Gtk::Widget::set_parent(Gtk::Widget&)' is protected
mycontainer.cc:20: error: within this context
...
(other messages like above with Gtk::Widget::unparent)
I have the same problem in a custom container I'm writting for a project
of mine but I don't understand the reason as the custom container is a
Gtk::Widget ...
I'm runinng a Debian unstable with gcc -v :
Lecture des spécification à partir de
/usr/lib/gcc-lib/i486-linux/3.3.5/specs
Configuré avec: ../src/configure -v
--enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared
--with-system-zlib --enable-nls --without-included-gettext
--enable-__cxa_atexit --enable-clocale=gnu --enable-debug
--enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc i486-linux
Modèle de thread: posix
version gcc 3.3.5 (Debian 1:3.3.5-1)
Is this a compiler bug or did I missed something ?
Thank you :)
PS : Sorry if my message is not correctly wrapped but I have trouble
with my email client :p
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]