[Gtk-sharp-list] Disposing a Gtk.FileSelection causes a crash

Miguel de Icaza miguel@ximian.com
11 Mar 2003 11:43:51 -0500


Hello!

> ====
> #include <glib.h>
> #include <gtk/gtkfilesel.h>
> 
> int
> main (int argc, char *argv [])
> {
> 	GtkFileSelection *fs;
> 
> 	gtk_init (&argc, &argv);
> 
> 	fs = gtk_file_selection_new ("test");
> 	g_object_unref (fs);
> }
> =====
> 
> I'm getting
> 
> ====
> (test-filesel:23975): GLib-GObject-WARNING **: instance of invalid non-instantiatable type `<invalid>'
> 
> (test-filesel:23975): GLib-GObject-CRITICAL **: file gsignal.c: line 1732 (g_signal_handlers_destroy): assertion `G_TYPE_CHECK_INSTANCE (instance)' failed
> Segmentation fault
> ====

I asked about this on the Gtk+ channel, and here are the answers:

	* You do not "own" the toplevel window objects, those are
	  owned by Gtk.

	* For those objects we should call `gtk_object_destroy' instead
	  of unref.

	* JamesH suggested instead that we g_object_ref the return value
	  of gtk_file_selection_new inside gtk#

So Martin, in Gtk#, what kind of object is giving you this problem, so
we can correctly address this?

The PyGtk people ran into the same issue too.

Alp suggested also that we have a ref metadata flag, so we should
probably use this.

Miguel.