]> Pileus Git - ~andy/gtk/commitdiff
Bug 557059 – crash when compositing emblems with icon
authorChristian Persch <chpe@gnome.org>
Mon, 20 Oct 2008 16:55:00 +0000 (16:55 +0000)
committerChristian Persch <chpe@src.gnome.org>
Mon, 20 Oct 2008 16:55:00 +0000 (16:55 +0000)
2008-10-20  Christian Persch  <chpe@gnome.org>

Bug 557059 – crash when compositing emblems with icon

* gtk/gtkicontheme.c: (apply_emblems): Copy the pixbuf before using it
with gtk_pixbuf_composite, in case its pixdata is read-only (mmaped
from icon cache or builtins).

svn path=/trunk/; revision=21690

ChangeLog
gtk/gtkicontheme.c

index f3bef2cc9973bc529af91bbc923b4e6775ad87dc..69982b19918915d1b16d420260d551d2b58ecb60 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-10-20  Christian Persch  <chpe@gnome.org>
+
+       Bug 557059 – crash when compositing emblems with icon
+
+       * gtk/gtkicontheme.c: (apply_emblems): Copy the pixbuf before using it
+       with gtk_pixbuf_composite, in case its pixdata is read-only (mmaped
+       from icon cache or builtins).
+
 2008-10-20  Murray Cumming  <murrayc@murrayc.com>
 
        * gtk/gtkiconview.c: gtk_icon_view_set_tooltip_row(), 
index 04ef756ba44ef5ed64484582e14135885ac93954..5fc1b3b20bf341e72ae38da789c43c5363c1337e 100644 (file)
@@ -2776,13 +2776,15 @@ static gboolean icon_info_ensure_scale_and_pixbuf (GtkIconInfo*, gboolean);
 static void 
 apply_emblems (GtkIconInfo *info)
 {
-  GdkPixbuf *icon;
+  GdkPixbuf *icon = NULL;
   gint w, h, pos;
   GSList *l;
 
-  icon = info->pixbuf;
-  w = gdk_pixbuf_get_width (icon);
-  h = gdk_pixbuf_get_height (icon);
+  if (info->emblem_infos == NULL)
+    return;
+
+  w = gdk_pixbuf_get_width (info->pixbuf);
+  h = gdk_pixbuf_get_height (info->pixbuf);
 
   for (l = info->emblem_infos, pos = 0; l; l = l->next, pos++)
     {
@@ -2826,10 +2828,23 @@ apply_emblems (GtkIconInfo *info)
               break;
             }
 
+          if (icon == NULL)
+            {
+              icon = gdk_pixbuf_copy (info->pixbuf);
+              if (icon == NULL)
+                break;
+            }
+
           gdk_pixbuf_composite (emblem, icon, x, y, ew, eh, x, y,
                                 scale, scale, GDK_INTERP_BILINEAR, 255);
        }
    }
+
+  if (icon)
+    {
+      g_object_unref (info->pixbuf);
+      info->pixbuf = icon;
+    }
 }
 
 /* This function contains the complicated logic for deciding