[g-a-devel] libgail-gnome patch to avoid major gnome-panel issues on 2.32.x

(please keep me in cc on replies)


After some discussion with Mike yesterday, and while debugging something
else that I thought was unrelated, we found a rather bad issue in
gnome-panel 2.32, which can be triggered because of libgail-gnome.

Because libpanel-applet-2 and libpanel-applet-3 share the same symbol
names, we should avoid putting them in the same process. It turns out
that if libgail-gnome is loaded and if there's an in-process
libpanel-applet-3 applet, then it will happen.

We can work around the issue, though: if we make sure that libgail-gnome
doesn't use any panel_applet_* symbols when it's running inside
gnome-panel, then libpanel-applet-2 won't be used. And the in-process
applets will be able to happily use the right code (ie,
libpanel-applet-3 code).

This patch for libgail-gnome implements this hack. It's really a bad
hack, but I can't think of a better way to do this.

Note that doing is this way should keep the bonobo applets accessible.



Les gens heureux ne sont pas pressés.
>From 3c0d6461f43279024539c441cdf9e71b8d045335 Mon Sep 17 00:00:00 2001
From: Vincent Untz <vuntz gnome org>
Date: Fri, 18 Feb 2011 12:16:38 +0100
Subject: [PATCH] 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.
 configure.in                           |    5 +++++
 gail-gnome/bonobo-accessibility-init.c |   16 +++++++++++++++-
 2 files changed, 20 insertions(+), 1 deletions(-)

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_DEFINE([HAVE_PANEL_APPLET_2_32], 1,
+                            [Build for libpanel-applet-2 >= 2.32.0 (ie, bonobo applets available only for compatibility)])],
+                 [])
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) {
+    atk_registry_set_factory_type (registry, PANEL_TYPE_APPLET, PANEL_APPLET_TYPE_ATK_OBJECT_FACTORY);
+#ifdef HAVE_PANEL_APPLET_2_32
+  }
 static void

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]