File libgail-no-bonobo-applet-in-panel.patch of Package libgail-gnome
commit 3c0d6461f43279024539c441cdf9e71b8d045335
Author: Vincent Untz <vuntz@gnome.org>
Date: Fri Feb 18 12:16:38 2011 +0100
Fix gnome-panel crashes & other issues on 2.32, when a11y is enabled
This is a horrible hack to fix a conflict between libpanel-applet-2 and
libpanel-applet-3 runnning in the same process (gnome-panel):
- if we're built against a recent version of libpanel-applet-2, used
only for compatibility with old bonobo applets, it means that
gnome-panel will mostly use dbus-based applets.
- in this case, we also know that there won't be any bonobo applets
running inside the gnome-panel process (guaranteed by a change in
libpanel-applet-2 API on gnome-2-32), and there are chances there
will be dbus applets running there.
- we also know that libpanel-applet-2 and libpanel-applet-3 share
panel_applet_* symbol names.
- this means that if we actually start using panel_applet_* symbols
here, and if those symbols haven't been resolved earlier, they will
get resolved to the libpanel-applet-2 symbols. As this GTK+ module
will likely be the first executed code needing panel_applet_*
symbols, we know it will happen.
- if the process that is running is gnome-panel, then it means dbus
applets will use libpanel-applet-2 symbols, instead of
libpanel-applet-3 applets. Causing various interesting crashes,
deadlocks or any other issues.
Conclusion: if we're gnome-panel, we do not want to touch in any way
panel_applet_* symbols in this GTK+ module.
(Obviously, if we're a bonobo applets, we do want to resolve those symbols
now, to libpanel-applet-2 symbols.)
Note that this only works because GTK+ loads modules with RTLD_LAZY, so
the symbols are resolved only when needed.
To detect the gnome-panel process, we use g_get_prgname(). If the
application running is really gnome-panel, then prgname will be
"gnome-panel". If the application running is not gnome-panel, then the
prgname is likely not "gnome-panel", and if it still is "gnome-panel",
then it's a weird application that won't need the bonobo applets anyway.
diff --git a/configure.in b/configure.in
index 35207d3..0d7afe5 100644
--- a/configure.in
+++ b/configure.in
@@ -146,6 +146,11 @@ AC_SUBST([AM_CPPFLAGS])
AC_SUBST([AM_CFLAGS])
AC_SUBST([AM_LDFLAGS])
+PKG_CHECK_EXISTS([$PANEL_APPLET_PACKAGES >= 2.32.0],
+ [AC_DEFINE([HAVE_PANEL_APPLET_2_32], 1,
+ [Build for libpanel-applet-2 >= 2.32.0 (ie, bonobo applets available only for compatibility)])],
+ [])
+
AC_CONFIG_FILES([
Makefile
libgail-gnome.pc
diff --git a/gail-gnome/bonobo-accessibility-init.c b/gail-gnome/bonobo-accessibility-init.c
index 748928a..041cca1 100644
--- a/gail-gnome/bonobo-accessibility-init.c
+++ b/gail-gnome/bonobo-accessibility-init.c
@@ -18,6 +18,8 @@
* Boston, MA 02111-1307, USA.
*/
+#include "config.h"
+
#include <stdio.h>
#include <glib-object.h>
#include <atk/atk.h>
@@ -93,7 +95,19 @@ gail_bonobo_ui_register_atk_factories (void)
AtkRegistry *registry = atk_get_default_registry ();
atk_registry_set_factory_type (registry, BONOBO_TYPE_PLUG, BONOBO_TYPE_PLUG_ATK_OBJECT_FACTORY);
atk_registry_set_factory_type (registry, BONOBO_TYPE_SOCKET, BONOBO_TYPE_SOCKET_ATK_OBJECT_FACTORY);
- atk_registry_set_factory_type (registry, PANEL_TYPE_APPLET, PANEL_APPLET_TYPE_ATK_OBJECT_FACTORY);
+#ifdef HAVE_PANEL_APPLET_2_32
+ /* This is a horrible hack to fix a conflict between libpanel-applet-2 and
+ * libpanel-applet-3 runnning in the gnome-panel process on 2.32. We do not
+ * want to resolve panel_applet_* symbols in this GTK+ module if we're in the
+ * gnome-panel process.
+ *
+ * See commit log for the long story. */
+ if (g_strcmp0 (g_get_prgname (), "gnome-panel") != 0) {
+#endif
+ atk_registry_set_factory_type (registry, PANEL_TYPE_APPLET, PANEL_APPLET_TYPE_ATK_OBJECT_FACTORY);
+#ifdef HAVE_PANEL_APPLET_2_32
+ }
+#endif
}
static void