[gnome-shell] Work around a Clutter crash when there is no root pixmap



commit b131ecc42a88c1e1765373fa7a216879c52ef4de
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Mon Jun 8 17:05:45 2009 -0400

    Work around a Clutter crash when there is no root pixmap
    
    When there is no root pixmap, the result will be a CoglMaterial
    with a layer with no texture, and that causes a crash.
    
    Work around this by supressing painting the root pixmap actor
    when there is no root pixmap.
    
    http://bugzilla.gnome.org/show_bug.cgi?id=585196

 src/shell-global.c |   26 ++++++++++++++++++++++++--
 1 files changed, 24 insertions(+), 2 deletions(-)
---
diff --git a/src/shell-global.c b/src/shell-global.c
index f3a4185..b1913f9 100644
--- a/src/shell-global.c
+++ b/src/shell-global.c
@@ -933,6 +933,7 @@ update_root_window_pixmap (ShellGlobal *global)
   gulong nitems;
   gulong bytes_after;
   guchar *data;
+  Pixmap root_pixmap_id = None;
 
   if (!XGetWindowProperty (gdk_x11_get_default_xdisplay (),
                            gdk_x11_get_default_root_xwindow (),
@@ -947,8 +948,7 @@ update_root_window_pixmap (ShellGlobal *global)
      if (type == XA_PIXMAP && format == 32 && nitems == 1)
        {
          /* Was what we expected. */
-         clutter_x11_texture_pixmap_set_pixmap (CLUTTER_X11_TEXTURE_PIXMAP (global->root_pixmap),
-                                                *(Pixmap *)data);
+         root_pixmap_id = *(Pixmap *)data;
        }
      else
        {
@@ -957,6 +957,9 @@ update_root_window_pixmap (ShellGlobal *global)
 
      XFree(data);
   }
+
+  clutter_x11_texture_pixmap_set_pixmap (CLUTTER_X11_TEXTURE_PIXMAP (global->root_pixmap),
+                                         root_pixmap_id);
 }
 
 /*
@@ -976,6 +979,22 @@ root_window_filter (GdkXEvent *native, GdkEvent *event, gpointer data)
   return GDK_FILTER_CONTINUE;
 }
 
+/* Workaround for a clutter bug where if ClutterGLXTexturePixmap
+ * is painted without the pixmap being set, a crash will occur inside
+ * Cogl.
+ *
+ * http://bugzilla.openedhand.com/show_bug.cgi?id=1644
+ */
+static void
+root_pixmap_paint (ClutterActor *actor, gpointer data)
+{
+  Pixmap pixmap;
+
+  g_object_get (G_OBJECT (actor), "pixmap", &pixmap, NULL);
+  if (!pixmap)
+    g_signal_stop_emission_by_name (actor, "paint");
+}
+
 /*
  * Called when the root window pixmap actor is destroyed.
  */
@@ -1021,6 +1040,9 @@ shell_global_create_root_pixmap_actor (ShellGlobal *global)
       clutter_container_add_actor (CLUTTER_CONTAINER (stage),
                                    global->root_pixmap);
 
+      g_signal_connect (global->root_pixmap, "paint",
+                        G_CALLBACK (root_pixmap_paint), NULL);
+
       /* This really should never happen; but just in case... */
       g_signal_connect (global->root_pixmap, "destroy",
                         G_CALLBACK (root_pixmap_destroy), global);



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