custom widget example from the gtkmm book is out of date



Hi,

I the custom widget example from the gtkmm book 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!


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