[gimp] app: g_type_class_unref() PixbufStyle in themes_exit().



commit ba8dca5f47a7cf40bf63ac2f26b079c3069327dc
Author: Jehan <jehan girinstud io>
Date:   Fri Dec 1 15:54:14 2017 +0100

    app: g_type_class_unref() PixbufStyle in themes_exit().
    
    Massimo is worried that it could unload the module (maybe in some
    specific cases?), which could indeed happen when the g_type_class_ref()
    just before was the first call to the class (hence it's the only ref).
    So let's just unref() in the exit() function instead.

 app/gui/themes.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/app/gui/themes.c b/app/gui/themes.c
index 6fa21ca..c756f02 100644
--- a/app/gui/themes.c
+++ b/app/gui/themes.c
@@ -65,7 +65,8 @@ static void   themes_draw_layout         (GtkStyle               *style,
 
 /*  private variables  */
 
-static GHashTable *themes_hash = NULL;
+static GHashTable *themes_hash             = NULL;
+static gpointer    pixbuf_style_type_class = NULL;
 
 
 /*  public functions  */
@@ -75,7 +76,6 @@ themes_init (Gimp *gimp)
 {
   GimpGuiConfig *config;
   gchar         *themerc;
-  gpointer       pixbuf_style_type_class;
 
   g_return_if_fail (GIMP_IS_GIMP (gimp));
 
@@ -91,7 +91,6 @@ themes_init (Gimp *gimp)
   if (pixbuf_style_type_class)
     {
       GTK_STYLE_CLASS (pixbuf_style_type_class)->draw_layout = themes_draw_layout;
-      g_type_class_unref (pixbuf_style_type_class);
     }
 
   config = GIMP_GUI_CONFIG (gimp->config);
@@ -182,6 +181,11 @@ themes_exit (Gimp *gimp)
       g_hash_table_destroy (themes_hash);
       themes_hash = NULL;
     }
+  if (pixbuf_style_type_class)
+    {
+      g_type_class_unref (pixbuf_style_type_class);
+      pixbuf_style_type_class = NULL;
+    }
 }
 
 gchar **


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