GNOME Bugzilla – Bug 585536
unique_app_new segfaults if gtk not initialized
Last modified: 2009-08-24 21:55:47 UTC
Hi, I use libunique 1.0.8 under Gnome 2.24. I notice that unique_app_new and unique_app_new_with_commands segfault if gtk_init is not called _before_ trying to allocate a new UniqueApp instance. g_type_init is not enough to avoid this. Simple code to reproduce : int main( int argc, char *argv[] ) { /* need to gtk_init before unique_app_new * g_type_init is not enough */ /*gtk_init( &argc, &argv );*/ g_type_init(); UniqueApp *app = unique_app_new( "org.my-domain.MyAppli", NULL ); g_object_unref( app ); return( 0 ); } (gdb) bt
+ Trace 215969
Maybe gtk_init should be called at the very earliest stage of the UI program, even if we don't know yet if we are going to actually run the application. So I don't know if it is really a bug, but I suggest at least updating the documentation. Regards, Pierre And many thanks for all your work...!
the example on the wiki page shows it: http://live.gnome.org/LibUnique the example code in the tarball shows it: http://git.gnome.org/cgit/unique/plain/tests/test-unique.c and unique depends on gtk+, so I assume people will use gtk+ properly. anyway, I'll add a note in the documentation.
fixed in master: commit a72ab58ea3b6e9ebb2735981c1266c09504c4b17 Author: Emmanuele Bassi <ebassi@gnome.org> Date: Mon Aug 24 22:50:21 2009 +0100 [docs] Add a note about requiring gtk_init() Be more explicit on requiring GTK+ to be initialized before using LibUnique. Fixes bug: http://bugzilla.gnome.org/show_bug.cgi?id=585536