tags:

views:

836

answers:

2

Whenever I close my Gtk# application, I get this:

(/home/matthew/opensbs/OpenSBS/bin/Debug/OpenSBS.exe:5050): GLib-WARNING **: g_set_prgname() called multiple times

(/home/matthew/opensbs/OpenSBS/bin/Debug/OpenSBS.exe:5050): GLib-GObject-WARNING **: instance with invalid (NULL) class pointer

(/home/matthew/opensbs/OpenSBS/bin/Debug/OpenSBS.exe:5050): GLib-GObject-CRITICAL **: g_signal_handlers_disconnect_matched: assertion `G_TYPE_CHECK_INSTANCE (instance)' failed

(/home/matthew/opensbs/OpenSBS/bin/Debug/OpenSBS.exe:5050): GLib-GObject-WARNING **: instance with invalid (NULL) class pointer

(/home/matthew/opensbs/OpenSBS/bin/Debug/OpenSBS.exe:5050): GLib-GObject-CRITICAL **: g_signal_handlers_disconnect_matched: assertion `G_TYPE_CHECK_INSTANCE (instance)' failed

(/home/matthew/opensbs/OpenSBS/bin/Debug/OpenSBS.exe:5050): GLib-GObject-WARNING **: instance with invalid (NULL) class pointer

(/home/matthew/opensbs/OpenSBS/bin/Debug/OpenSBS.exe:5050): GLib-GObject-CRITICAL **: g_signal_handlers_disconnect_matched: assertion `G_TYPE_CHECK_INSTANCE (instance)' failed

(/home/matthew/opensbs/OpenSBS/bin/Debug/OpenSBS.exe:5050): GLib-GObject-WARNING **: instance with invalid (NULL) class pointer

(/home/matthew/opensbs/OpenSBS/bin/Debug/OpenSBS.exe:5050): GLib-GObject-CRITICAL **: g_signal_handlers_disconnect_matched: assertion `G_TYPE_CHECK_INSTANCE (instance)' failed

(/home/matthew/opensbs/OpenSBS/bin/Debug/OpenSBS.exe:5050): GLib-GObject-CRITICAL **: g_object_ref: assertion `object->ref_count > 0' failed

I'm not really sure what's going on here. I found one person with a similar problem on google, but they seemed to be a user of an application, not a developer. An ideas?

A: 

Well, I'm still not sure what the warning means, but I figured out what was causing it:

I had a glade file with an AccelGroup in it. The AccelGroup was a property of the main Window and its MenuItems. I removed it from the Window. This is when the warning started. I fixed it by also deleting it from the glade file entirely (thus removing it from the menu items).

Matthew
+2  A: 

Something's pretty messed-up.

g_set_prgname() is an internal routine that's normally only called by a program initializer like gdk_init() or gtk_init() (which calls gdk_init()). So if it's being called twice, well, it shouldn't. I read your answer, and perhaps some Glade initialization routine is calling it redundantly. It would help to know what versions of Glade and GTK you're running.

As far as the other messages... GLib/GObject is an object system, with single-inheritance and RTTI (run-time type identification), implemented in C.

Those warning/critical pairs indicate that your some object pointers are failing an RTTI test pretty miserably. Such tests are common in GTK/GDK internals - things like, "I'm expecting this pointer to be a such-and-such, but I better make sure before I treat it that way." Each message pair you see indicates a pointer has been passed to such a routine, but what it points to is not only not the expected object type, it's not even pointing to anything the RTTI system recognizes, so the RTTI system is throwing up its hands.

The most likely culprits for such a pointer failing like that is:

  • It's a wild pointer that points to junk
  • It's stale - it used to point a legitimate object that has since been destructed
  • It points to a live object, but the object's contents have become corrupted so badly, the RTTI system can't figure out the object's type
Bob Murphy
I'm using Gtk 2.18.3-1ubuntu2.1 and the built-in GtkBuilder to process the glade files. The glade files are editted using Glade 3.6.7-1ubuntu1. If it matters, I'm also using gnome-globalmenu (http://code.google.com/p/gnome2-globalmenu/), which sometimes introduces weird warnings to Gtk. I get the g_set_prgname() warning every time I run my application, not just when quitting.
Matthew
Wow - I didn't know about GlobalMenu. Makes Ubuntu look like a Mac! Anyway, I looked at some 1-2 year old sources for g_set_prgname(), and those wouldn't have generated that warning, so I figured yours must be newer. You could try writing a minimal Gtk# program and see if that also emits the warning. That will tell you if it's something specific to your program, or something more general, like GlobalMenu or a bug in the Gtk# bindings to GTK.
Bob Murphy