From d478ae1ef5731a0e0005875589575f8c1b91a5b9 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Thu, 30 Jan 2020 18:19:56 +0100 Subject: [PATCH] icon-theme: Avoid reentrancy issues while loading icon theme 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 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c index a3566de5b4..2d04f8684b 100644 --- a/gtk/gtkicontheme.c +++ b/gtk/gtkicontheme.c @@ -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); }