querying object args and gtk+ class initialisation
- From: Michael Beach <michaelb ieee org>
- To: gtk-list redhat com
- Subject: querying object args and gtk+ class initialisation
- Date: Sat, 24 Apr 1999 05:38:48 +1000 (EST)
Greetings gtk+ gurus...
In the course of fiddling about with gtk+ (version 1.2.1), I have been
attempting to use the gtk_object_query_args() function in the context of the
following program fragment...
int main(int argc, char *argv)
type_id = gtk_type_from_name("GtkWindow");
/* gtk_type_class(type_id); */
arg_array = gtk_object_query_args(type_id, NULL, &num_args);
Unfortunately, when I run it, it comes back with...
Gtk-CRITICAL **: file gtkarg.c: line 338 (gtk_args_query): assertion
`arg_info_hash_table != NULL' failed.
After some digging, I discovered that in this case arg_info_hash_table was
assigned the value of the object_arg_info_ht, a static in gtkobject.c. In order
to ensure that this was not null, it was necessary to ensure that
gtk_object_add_arg_type() was called. However this function seems to be
called when a class is initialised.
Paradoxically though, gtk_args_query() contains the following snippet of code...
g_return_val_if_fail (arg_info_hash_table != NULL, NULL);
/* make sure the types class has been initialized, because
* the argument setup happens in the gtk_*_class_init() functions.
ie it wants to call gtk_type_class() to ensure that class initialisation is
done, but unless some class has been previously initialised through some other
path of execution it can never get that far, as it will bomb out due to
arg_info_hash_table being uninitialised. Indeed, when the call to
gtk_type_class() is uncommented in my code fragment above, the error goes away,
as the call results in object_arg_info_ht being initialised.
To me, all of this looks like a bit of a buglet. Admittedly, it probably won't
bite many people as most will initialise at least one class before performing
any args queries, but it is still a bit of a blemish. IMHO, the cleanest fix
would be to initialise object_arg_info_ht (directly or indirectly) from
gtk_init(). Should I just prepare a patch to this effect and post it to the
list, or has this been fixed in 1.2.2, or am I barking up the wrong tree here?
"People who fight may lose. People who do not fight have already lost."
-- Bertolt Brecht
] [Thread Prev