Re: custom widget example from the gtkmm book is out of date



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 <sledgehammer_999 hotmail com>
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: bastien dallapiazza gmail com
To: gtkmm-list gnome org


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!


Hotmail: Αξιόπιστο email με ισχυρή προστασία ενάντια στην ανεπιθύμητη αλληλογραφία. Εγγραφείτε τώρα.

_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list




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