[Gtk-sharp-list] GLib.Object.Dispose questions

Bruno Fernandez-Ruiz brunofr@olympum.com
Thu, 02 Oct 2003 08:11:22 +0300


Hi,

I am getting an exception in my Gtk# application which has led me to
looking into the Dispose() method of GLib.Object. The exception I get
is:

System.NullReferenceException: A null value was found where an object
instance was required
in (unmanaged) (wrapper managed-to-native) GLib.Object:g_object_unref
(intptr)
in <0x00004> (wrapper managed-to-native) GLib.Object:g_object_unref
(intptr)
in <0x0014a> GLib.Object:PerformQueuedUnrefs ()
in <0x0001b> (wrapper native-to-managed) GLib.Object:PerformQueuedUnrefs
()
in (unmanaged) (wrapper managed-to-native) Gtk.Application:gtk_main ()
in <0x00004> (wrapper managed-to-native) Gtk.Application:gtk_main ()
in <0x00007> Gtk.Application:Run ()

which I guess means that although the managed object is still referenced
by the PendingDestroys Queue, the unmanaged GLibObject has been already
unreferenced.

Only sometimes the exception comes together with native messages:

(<unknown>:3822): GLib-GObject-WARNING **: instance of invalid
non-instantiatable type `guchar'

(<unknown>:3822): GLib-GObject-CRITICAL **: file gsignal.c: line 2056
(g_signal_handlers_destroy): assertion `G_TYPE_CHECK_INSTANCE
(instance)' failed


Now, my questions are:

1. What is the design decision behind making the Dispose () method
schedule the PerformQueuedUnrefs() for an idle of the gtk_main and not
just calling g_object_unref when the object is being disposed?

2. The header of Object.cs has a TODO:
// TODO:
//   Could remove `disposed' for a check if an object is on the
dispose_queue_list.
//
what is dispose_queue_list? I looked into the public g_object API, but
could not find anything.

Thanks
Bruno