Le 30/12/2010 14:36, Josselin Mouette a écrit :
Le mercredi 29 décembre 2010 à 16:36 +0100, Bastien a écrit :
That's a bug in the library. Even the simplest code I write using
Gnome::Panel::Applet causes a segfault, but that works fine if I use the
C libpanel-applet library directly.
I used gdb on the test-bonobo-applet program provided with
libpanel-applet. This time, gdk_display isn't NULL. I don't know where
gdk_display is set, but the issue in libpanelappletmm comes from there.
It should be set by running gtk_init(). If it’s not in example, that’s
obviously a bug in it, not in the library.
Cheers,
libpanelappletmm is a C++ library using gtkmm, which is a wrapper for
GTK+. Having to call gtk_init directly when using libpanelappletmm would
be a design flaw. Look at the source of some gtkmm-based programs : they
don't call gtk_init, instead they create a Gtk::Main which calls it.
The example calls Gnome::Panel::init. This function should initializes
every needed component (so gtk as well).
Looking at libpanelappletmm's source, Gnome::Panel::init just calls
Gtk::Main::init_gtkmm_internals, which doesn't call gtk_init.
Gnome::Panel::init should create (and keep) an Gtk::Main instance, so
gtk_init get called.
I provided a patch. The example applets now fully work. (Note there's
maybe a better way to store the Gtk::Main)
--- libpanelapplet/libpanelappletmm/init.cc-old 2010-12-30 15:21:38.000000000
+0100
+++ libpanelapplet/libpanelappletmm/init.cc 2010-12-30 15:21:43.000000000
+0100
@@ -35,7 +35,7 @@
void init(const Glib::ustring& app_id, const Glib::ustring& app_version, int
argc, char** argv)
{
- Gtk::Main::init_gtkmm_internals(); //Sets up the g type system and the
Glib::wrap() table.
+ static Gtk::Main kit(argc, argv);
wrap_init(); //Tells the Glib::wrap() table about the libpanelappletmm
classes.
bonobo_init(&argc, argv);
}