icon-theme: Avoid reentrancy issues while loading icon theme
authorAlexander Larsson <alexl@redhat.com>
Thu, 30 Jan 2020 17:19:56 +0000 (18:19 +0100)
committerAlexander Larsson <alexl@redhat.com>
Thu, 30 Jan 2020 17:19:56 +0000 (18:19 +0100)
In gtk_icon_theme_get_for_display() we were calling
gtk_icon_theme_set_display() which eventually (via the css machinery)
called back into gtk_icon_theme_get_for_display() which created a
second icon theme. We avoid this by setting the user-data earlier so
that the css machinery gets back the currently initializing theme
instead.

gtk/gtkicontheme.c

index a3566de5b4af2d97477d720609fc19887d053196..2d04f8684bed70869a00e9bcf8b71f88e50b4c69 100644 (file)
@@ -789,12 +789,13 @@ gtk_icon_theme_get_for_display (GdkDisplay *display)
   if (!self)
     {
       self = gtk_icon_theme_new ();
-      gtk_icon_theme_set_display (self, display);
-
       self->is_display_singleton = TRUE;
 
       g_object_set_data (G_OBJECT (display), I_("gtk-icon-theme"), self);
 
+      /* Call this after setting the user-data, because it recurses into gtk_icon_theme_get_for_display via the thememing machinery */
+      gtk_icon_theme_set_display (self, display);
+
       /* Queue early read of the default themes, we read the icon theme name in _set_display(). */
       gtk_icon_theme_load_in_thread (self);
     }