[gimp] app: don't additionally ref the standard data objects



commit c9bde335f0e9ca2db51fa436f75d6992193df365
Author: Michael Natterer <mitch gimp org>
Date:   Thu Jun 24 12:46:45 2010 +0200

    app: don't additionally ref the standard data objects
    
    Instead, set their statically remembered pointer as a weak pointer so
    it's nullified automatically if they are ever finalized. Doesn't
    actually get rid of them upon exit yet, this is just a preparation.

 app/core/gimpbrush.c      |    3 ++-
 app/core/gimpdynamics.c   |    3 ++-
 app/core/gimpgradient.c   |    3 ++-
 app/core/gimppalette.c    |    3 ++-
 app/core/gimppattern.c    |    3 ++-
 app/core/gimptoolpreset.c |    3 ++-
 6 files changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/app/core/gimpbrush.c b/app/core/gimpbrush.c
index d5187b5..1d12558 100644
--- a/app/core/gimpbrush.c
+++ b/app/core/gimpbrush.c
@@ -421,7 +421,8 @@ gimp_brush_get_standard (GimpContext *context)
       gimp_data_clean (standard_brush);
       gimp_data_make_internal (standard_brush, "gimp-brush-standard");
 
-      g_object_ref (standard_brush);
+      g_object_add_weak_pointer (G_OBJECT (standard_brush),
+                                 (gpointer *) &standard_brush);
     }
 
   return standard_brush;
diff --git a/app/core/gimpdynamics.c b/app/core/gimpdynamics.c
index d4994b3..e461788 100644
--- a/app/core/gimpdynamics.c
+++ b/app/core/gimpdynamics.c
@@ -422,7 +422,8 @@ gimp_dynamics_get_standard (GimpContext *context)
       gimp_data_clean (standard_dynamics);
       gimp_data_make_internal (standard_dynamics, "gimp-dynamics-standard");
 
-      g_object_ref (standard_dynamics);
+      g_object_add_weak_pointer (G_OBJECT (standard_dynamics),
+                                 (gpointer *) &standard_dynamics);
     }
 
   return standard_dynamics;
diff --git a/app/core/gimpgradient.c b/app/core/gimpgradient.c
index 7ee4a48..d3a4e8b 100644
--- a/app/core/gimpgradient.c
+++ b/app/core/gimpgradient.c
@@ -351,7 +351,8 @@ gimp_gradient_get_standard (GimpContext *context)
       gimp_data_clean (standard_gradient);
       gimp_data_make_internal (standard_gradient, "gimp-gradient-standard");
 
-      g_object_ref (standard_gradient);
+      g_object_add_weak_pointer (G_OBJECT (standard_gradient),
+                                 (gpointer *) &standard_gradient);
     }
 
   return standard_gradient;
diff --git a/app/core/gimppalette.c b/app/core/gimppalette.c
index 075b8ac..cc35b22 100644
--- a/app/core/gimppalette.c
+++ b/app/core/gimppalette.c
@@ -295,7 +295,8 @@ gimp_palette_get_standard (GimpContext *context)
       gimp_data_clean (standard_palette);
       gimp_data_make_internal (standard_palette, "gimp-palette-standard");
 
-      g_object_ref (standard_palette);
+      g_object_add_weak_pointer (G_OBJECT (standard_palette),
+                                 (gpointer *) &standard_palette);
     }
 
   return standard_palette;
diff --git a/app/core/gimppattern.c b/app/core/gimppattern.c
index 3cab497..f216ed2 100644
--- a/app/core/gimppattern.c
+++ b/app/core/gimppattern.c
@@ -249,7 +249,8 @@ gimp_pattern_get_standard (GimpContext *context)
       gimp_data_clean (standard_pattern);
       gimp_data_make_internal (standard_pattern, "gimp-pattern-standard");
 
-      g_object_ref (standard_pattern);
+      g_object_add_weak_pointer (G_OBJECT (standard_pattern),
+                                 (gpointer *) &standard_pattern);
     }
 
   return standard_pattern;
diff --git a/app/core/gimptoolpreset.c b/app/core/gimptoolpreset.c
index 8440b0b..e37798d 100644
--- a/app/core/gimptoolpreset.c
+++ b/app/core/gimptoolpreset.c
@@ -446,7 +446,8 @@ gimp_tool_preset_get_standard (GimpContext *context)
       gimp_data_clean (standard_tool_preset);
       gimp_data_make_internal (standard_tool_preset, "gimp-tool-preset-standard");
 
-      g_object_ref (standard_tool_preset);
+      g_object_add_weak_pointer (G_OBJECT (standard_tool_preset),
+                                 (gpointer *) &standard_tool_preset);
     }
 
   return standard_tool_preset;



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