Hi,

I added an output to each method of the custom widget "MyWidget" so one can
track whether they are being used. One gets the following:

MyWidget::MyWidget()
MyWidget::on_size_request(Gtk::Requisition* requisition)
MyWidget::on_size_allocate(Gtk::Allocation& allocation)
MyWidget::on_realize()
MyWidget::on_map()
MyWidget::on_size_request(Gtk::Requisition* requisition)
MyWidget::on_size_allocate(Gtk::Allocation& allocation)
MyWidget::on_expose_event(GdkEventExpose* event)
MyWidget::on_expose_event(GdkEventExpose* event)
MyWidget::~MyWidget()

(test:3431): Gdk-WARNING **: losing last reference to undestroyed window


(test:3431): Gdk-CRITICAL **: gdk_window_hide: assertion `GDK_IS_WINDOW
(window)' failed

(test:3431): Gdk-CRITICAL **: gdk_window_set_user_data: assertion
`GDK_IS_WINDOW (window)' failed

(test:3431): Gdk-CRITICAL **: _gdk_window_destroy_hierarchy: assertion
`GDK_IS_WINDOW (window)' failed

(test:3431): GLib-GObject-CRITICAL **: g_object_unref: assertion
`G_IS_OBJECT (object)' failed

One thing is that the methods "MyWidget::on_unrealize()" and
"MyWidget::on_unmap()" are never called. I also tried to call them
nonetheless in the MyWidget destructor, the above warning is then emitted
when doing "m_refGdkWindow.clear()", that is precisely dropping the last
reference to the Gdk::Window. The question really is: how and where should
this Gdk::Window be destroyed (there is no "destroy" method in Gdk::Window,
just the destructor which cannot (should not) be called directly because we
only have a Glib::RefPtr<Gdk::Window> reference in the Gdk::Window).

Cheers!

2010/2/14 sledge hammer <[email protected]>

>  Good questions and remarks. As for the warnings, I've already filed a bug
> sometime ago but noone has done anything about it. The bug-->
> http://bugzilla.gnome.org/show_bug.cgi?id=606903
>
>
>
> ------------------------------
> Date: Sun, 14 Feb 2010 11:26:42 +0100
> Subject: custom widget example from the gtkmm book is out of date
> From: [email protected]
> To: [email protected]
>
>
> Hi,
>
> I the custom widget example from the gtkmm 
> book<http://library.gnome.org/devel/gtkmm-tutorial/unstable/sec-custom-widgets.html.en>seems
>  to be out of date as it generates the following errors when ending:
>
> *(test:2683): Gdk-WARNING **: losing last reference to undestroyed window
>
>
> (test:2683): Gdk-CRITICAL **: gdk_window_hide: assertion `GDK_IS_WINDOW
> (window)' failed
>
> (test:2683): Gdk-CRITICAL **: gdk_window_set_user_data: assertion
> `GDK_IS_WINDOW (window)' failed
>
> (test:2683): Gdk-CRITICAL **: _gdk_window_destroy_hierarchy: assertion
> `GDK_IS_WINDOW (window)' failed
>
> (test:2683): GLib-GObject-CRITICAL **: g_object_unref: assertion
> `G_IS_OBJECT (object)' failed*
>
> This has to do with the Gdk::Window created in the mywidget::on_realize
> method. It is not properly destroyed at the end of the example program.
>
> I've been playing with gtkmm for about a year now, and I found the way to
> create new widgets extremely confusing and I found nowhere a proper
> documentation about that (except the above example):
>
> The reason for having two "constructor methods" called successively, the
> actual constructor and the on_realize method (and on the other hand
> destructor and on_unrealize for destruction) is unclear.
> I understand it has to do with the low-level Gdk resources, but for
> instance in this example, how is the Gdk::Window destroyed? Does the
> programmer have the responsability to destroy it or should he bother only
> about the Gtk widgets?
>
> Cheers!
>
> ------------------------------
> Hotmail: Αξιόπιστο email με ισχυρή προστασία ενάντια στην ανεπιθύμητη
> αλληλογραφία. Εγγραφείτε τώρα.<https://signup.live.com/signup.aspx?id=60969>
>
> _______________________________________________
> gtkmm-list mailing list
> [email protected]
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
>
>
_______________________________________________
gtkmm-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Reply via email to