[gnome-shell] st-texture-cache: Add API to remove cache data



commit dc9ad8df8074cac9181a00699188809d05737d8e
Author: Florian MÃllner <fmuellner gnome org>
Date:   Fri Sep 21 16:00:44 2012 +0200

    st-texture-cache: Add API to remove cache data
    
    The current API assumes that image data loaded from files remains
    valid during the life time of the shell. This assumption is mostly
    valid for image files we provide ourselves (with the exception being
    designers working on those files), but not necessarily for "external"
    files - provide API to explicitly remove cached data associated with
    a URI for those cases.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=679268

 src/st/st-texture-cache.c |   27 +++++++++++++++++++++++++++
 src/st/st-texture-cache.h |    3 +++
 2 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/src/st/st-texture-cache.c b/src/st/st-texture-cache.c
index f76543e..2111432 100644
--- a/src/st/st-texture-cache.c
+++ b/src/st/st-texture-cache.c
@@ -94,6 +94,33 @@ st_texture_cache_class_init (StTextureCacheClass *klass)
                   G_TYPE_NONE, 0);
 }
 
+/**
+ * st_texture_cache_clear_uri:
+ * @cache: A #StTextureCache
+ * @uri: URI of cached object
+ *
+ * If the given @uri is known to have been modified
+ * externally, this function may be used to invalidate
+ * the in-memory cache.
+ */
+void
+st_texture_cache_clear_uri (StTextureCache *cache,
+                            const char     *uri)
+{
+  char *key;
+
+  g_return_if_fail (ST_IS_TEXTURE_CACHE (cache));
+  g_return_if_fail (uri != NULL);
+
+  key = g_strconcat (CACHE_PREFIX_URI, uri, NULL);
+  g_hash_table_remove (cache->priv->keyed_cache, key);
+  g_free (key);
+
+  key = g_strconcat (CACHE_PREFIX_URI_FOR_CAIRO, uri, NULL);
+  g_hash_table_remove (cache->priv->keyed_cache, key);
+  g_free (key);
+}
+
 /* Evicts all cached textures for named icons */
 static void
 st_texture_cache_evict_icons (StTextureCache *cache)
diff --git a/src/st/st-texture-cache.h b/src/st/st-texture-cache.h
index fc7dac2..b5c563b 100644
--- a/src/st/st-texture-cache.h
+++ b/src/st/st-texture-cache.h
@@ -68,6 +68,9 @@ GType st_texture_cache_get_type (void) G_GNUC_CONST;
 
 StTextureCache* st_texture_cache_get_default (void);
 
+void st_texture_cache_clear_uri (StTextureCache *cache,
+                                 const gchar    *uri);
+
 ClutterActor *
 st_texture_cache_load_sliced_image (StTextureCache    *cache,
                                     const gchar       *path,



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