Critical warnings from GTK objects after disposal but before finalization
It was noted in a discussion on Discourse that the GtkFontButton
widget was observed producing critical warnings after it had been disposed but not finalized due to the property "font" being set. This behaviour of the GtkFontWidget appears to violate the required behaviour of a GObject: according to the GObject reference manual, object methods should be able to run without program error after their object has been disposed but before it has been finalized. These critical warnings appear to be due to use of private state that has already been finalized.
This initial observation led to consideration of how other widgets protect against used of private state once disposed. The first widget considered was GtkAboutDialog. However it appears that this widget does not have the required protection as shown by the following example:
/* gcc test_set_after_dispose.c `pkg-config --cflags --libs gtk+-3.0` */
#include <gtk/gtk.h>
int main (int argc, gchar *argv[])
{
GtkWidget *about;
gtk_init (&argc, &argv);
about = gtk_about_dialog_new ();
g_object_ref_sink (about);
gtk_about_dialog_set_version (GTK_ABOUT_DIALOG (about), "1.2.3");
gtk_widget_realize (about);
/* Should uncommenting this disposal expression affect the subsequent
* `gtk_about_dialog_set_version` ? I didn't think so but doing so
* results in critical warnings from `gtk_about_dialog_set_version`.
g_object_run_dispose (G_OBJECT (about));
*/
gtk_about_dialog_set_version (GTK_ABOUT_DIALOG (about), "2.3.4");
g_object_unref (about);
return 0;
}
No further investigation has been done, pending confirmation of whether there is actually an issue in these cases.