[gtk/wip/baedert/for-master: 6/11] iconcache: ref textures



commit 26566830c65c0e22e9308b71b23491ae39e58619
Author: Timm Bäder <mail baedert org>
Date:   Sat Aug 10 19:36:56 2019 +0200

    iconcache: ref textures
    
    We can't just assume that the pointer we'se using as a cache key will
    stay unique forever. The texture might be freed, and a later allocated
    texture might have the same addres now, causing the cache to return
    incorrect results.

 gsk/gl/gskgliconcache.c | 3 +++
 1 file changed, 3 insertions(+)
---
diff --git a/gsk/gl/gskgliconcache.c b/gsk/gl/gskgliconcache.c
index bb66e8dfaf..4030bf7fbe 100644
--- a/gsk/gl/gskgliconcache.c
+++ b/gsk/gl/gskgliconcache.c
@@ -13,11 +13,13 @@ typedef struct
   GskGLTextureAtlas *atlas;
   int frame_age; /* Number of frames this icon is unused */
   guint used: 1;
+  GdkTexture *source_texture;
 } IconData;
 
 static void
 icon_data_free (gpointer p)
 {
+  g_object_unref (((IconData *)p)->source_texture);
   g_free (p);
 }
 
@@ -182,6 +184,7 @@ gsk_gl_icon_cache_lookup_or_add (GskGLIconCache  *self,
     icon_data->atlas = atlas;
     icon_data->frame_age = 0;
     icon_data->used = TRUE;
+    icon_data->source_texture = g_object_ref (texture);
     graphene_rect_init (&icon_data->texture_rect,
                         (float)(packed_x + 1) / atlas->width,
                         (float)(packed_y + 1) / atlas->height,


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