Blame SOURCES/0001-st-texture-cache-Cancel-pending-requests-on-icon-the.patch

5731ec
From 1bf28eea64056846547ec33d783c7f2e0dad78a4 Mon Sep 17 00:00:00 2001
5731ec
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
5731ec
Date: Fri, 22 May 2020 22:53:39 +0200
5731ec
Subject: [PATCH] st/texture-cache: Cancel pending requests on icon-theme
5731ec
 changes
5731ec
5731ec
As outlined in commit 36b8dcbe07, we can end up with wrong icons
5731ec
if the icon theme changes right after a GTK theme change to/from
5731ec
HighContrast triggered a theme reload.
5731ec
5731ec
That's because when we reload icons for the new icon theme, there
5731ec
are already pending requests due to the icon-style change; those
5731ec
requests are simply re-used for the new icons, with the existing
5731ec
icon infos from the old theme.
5731ec
5731ec
The above commit applied a simple work-around by changing the
5731ec
icon theme before the GTK theme, but that only works for the
5731ec
HighContrast switch in our own UI.
5731ec
5731ec
It turns out that Settings also uses the "wrong" order, so the
5731ec
issue still reproduces with the Universal Access panel.
5731ec
5731ec
So instead of relying on everything changing the settings in the
5731ec
order we expect, cancel all ongoing requests on icon-theme changes.
5731ec
5731ec
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1277
5731ec
---
5731ec
 src/st/st-texture-cache.c | 17 +++++++++++++++--
5731ec
 1 file changed, 15 insertions(+), 2 deletions(-)
5731ec
5731ec
diff --git a/src/st/st-texture-cache.c b/src/st/st-texture-cache.c
5731ec
index 35e9d036f..6dc351282 100644
5731ec
--- a/src/st/st-texture-cache.c
5731ec
+++ b/src/st/st-texture-cache.c
5731ec
@@ -48,6 +48,8 @@ struct _StTextureCachePrivate
5731ec
 
5731ec
   /* File monitors to evict cache data on changes */
5731ec
   GHashTable *file_monitors; /* char * -> GFileMonitor * */
5731ec
+
5731ec
+  GCancellable *cancellable;
5731ec
 };
5731ec
 
5731ec
 static void st_texture_cache_dispose (GObject *object);
5731ec
@@ -152,6 +154,9 @@ on_icon_theme_changed (StSettings     *settings,
5731ec
 {
5731ec
   g_autofree gchar *theme;
5731ec
 
5731ec
+  g_cancellable_cancel (cache->priv->cancellable);
5731ec
+  g_cancellable_reset (cache->priv->cancellable);
5731ec
+
5731ec
   st_texture_cache_evict_icons (cache);
5731ec
 
5731ec
   g_object_get (settings, "gtk-icon-theme", &theme, NULL);
5731ec
@@ -186,6 +191,8 @@ st_texture_cache_init (StTextureCache *self)
5731ec
   self->priv->file_monitors = g_hash_table_new_full (g_file_hash, (GEqualFunc) g_file_equal,
5731ec
                                                      g_object_unref, g_object_unref);
5731ec
 
5731ec
+  self->priv->cancellable = g_cancellable_new ();
5731ec
+
5731ec
   on_icon_theme_changed (settings, NULL, self);
5731ec
 }
5731ec
 
5731ec
@@ -194,8 +201,11 @@ st_texture_cache_dispose (GObject *object)
5731ec
 {
5731ec
   StTextureCache *self = (StTextureCache*)object;
5731ec
 
5731ec
+  g_cancellable_cancel (self->priv->cancellable);
5731ec
+
5731ec
   g_clear_object (&self->priv->settings);
5731ec
   g_clear_object (&self->priv->icon_theme);
5731ec
+  g_clear_object (&self->priv->cancellable);
5731ec
 
5731ec
   g_clear_pointer (&self->priv->keyed_cache, g_hash_table_destroy);
5731ec
   g_clear_pointer (&self->priv->keyed_surface_cache, g_hash_table_destroy);
5731ec
@@ -675,11 +685,14 @@ load_texture_async (StTextureCache       *cache,
5731ec
           gtk_icon_info_load_symbolic_async (data->icon_info,
5731ec
                                              &foreground_color, &success_color,
5731ec
                                              &warning_color, &error_color,
5731ec
-                                             NULL, on_symbolic_icon_loaded, data);
5731ec
+                                             cache->priv->cancellable,
5731ec
+                                             on_symbolic_icon_loaded, data);
5731ec
         }
5731ec
       else
5731ec
         {
5731ec
-          gtk_icon_info_load_icon_async (data->icon_info, NULL, on_icon_loaded, data);
5731ec
+          gtk_icon_info_load_icon_async (data->icon_info,
5731ec
+                                         cache->priv->cancellable,
5731ec
+                                         on_icon_loaded, data);
5731ec
         }
5731ec
     }
5731ec
   else
5731ec
-- 
5731ec
2.26.2
5731ec