[gimp] app: free the default brush, pattern etc in gimp_finalize()



commit e6ce0dda9d2aec9cc3d2776787f0b61ff3f68b66
Author: Michael Natterer <mitch gimp org>
Date:   Mon Oct 6 20:35:24 2014 +0200

    app: free the default brush, pattern etc in gimp_finalize()
    
    and print a warning if there are any contexts left in gimp->context_list.

 app/core/gimp.c |   25 ++++++++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)
---
diff --git a/app/core/gimp.c b/app/core/gimp.c
index 68bd32c..3c27874 100644
--- a/app/core/gimp.c
+++ b/app/core/gimp.c
@@ -348,11 +348,23 @@ gimp_dispose (GObject *object)
 static void
 gimp_finalize (GObject *object)
 {
-  Gimp *gimp = GIMP (object);
+  Gimp  *gimp      = GIMP (object);
+  GList *standards = NULL;
 
   if (gimp->be_verbose)
     g_print ("EXIT: %s\n", G_STRFUNC);
 
+  standards = g_list_prepend (standards,
+                              gimp_brush_get_standard (gimp->user_context));
+  standards = g_list_prepend (standards,
+                              gimp_dynamics_get_standard (gimp->user_context));
+  standards = g_list_prepend (standards,
+                              gimp_pattern_get_standard (gimp->user_context));
+  standards = g_list_prepend (standards,
+                              gimp_gradient_get_standard (gimp->user_context));
+  standards = g_list_prepend (standards,
+                              gimp_palette_get_standard (gimp->user_context));
+
   gimp_contexts_exit (gimp);
 
   if (gimp->image_new_last_template)
@@ -512,10 +524,21 @@ gimp_finalize (GObject *object)
 
   if (gimp->context_list)
     {
+      GList *list;
+
+      g_warning ("%s: list of contexts not empty upon exit (%d contexts left)\n",
+                 G_STRFUNC, g_list_length (gimp->context_list));
+
+      for (list = gimp->context_list; list; list = g_list_next (list))
+        g_printerr ("stale context: %s\n", gimp_object_get_name (list->data));
+
       g_list_free (gimp->context_list);
       gimp->context_list = NULL;
     }
 
+  g_list_foreach (standards, (GFunc) g_object_unref, NULL);
+  g_list_free (standards);
+
   gimp_units_exit (gimp);
 
   G_OBJECT_CLASS (parent_class)->finalize (object);


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