[gtk+] csskeyframes: unref GtkCssValues when free-ing



commit 97f49c681bb42fd3b88d2b85bd10ba6dbf00a4bf
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Tue Oct 16 11:52:59 2012 -0400

    csskeyframes: unref GtkCssValues when free-ing
    
    We assume a reference to all the GtkCssValues we store, so we need to
    release it when free-ing.

 gtk/gtkcsskeyframes.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkcsskeyframes.c b/gtk/gtkcsskeyframes.c
index f909871..dc214b2 100644
--- a/gtk/gtkcsskeyframes.c
+++ b/gtk/gtkcsskeyframes.c
@@ -36,6 +36,8 @@ struct _GtkCssKeyframes {
   GtkCssValue **values;         /* 2D array: n_keyframes * n_properties of (value or NULL) for all the keyframes */
 };
 
+#define KEYFRAMES_VALUE(keyframes, k, p) ((keyframes)->values[(k) * (keyframes)->n_properties + (p)])
+
 GtkCssKeyframes *
 _gtk_css_keyframes_ref (GtkCssKeyframes *keyframes)
 {
@@ -49,6 +51,8 @@ _gtk_css_keyframes_ref (GtkCssKeyframes *keyframes)
 void
 _gtk_css_keyframes_unref (GtkCssKeyframes *keyframes)
 {
+  guint k, p;
+
   g_return_if_fail (keyframes != NULL);
 
   keyframes->ref_count--;
@@ -57,13 +61,20 @@ _gtk_css_keyframes_unref (GtkCssKeyframes *keyframes)
 
   g_free (keyframes->keyframe_progress);
   g_free (keyframes->property_ids);
+
+  for (k = 0; k < keyframes->n_keyframes; k++)
+    {
+      for (p = 0; p < keyframes->n_properties; p++)
+        {
+          _gtk_css_value_unref (KEYFRAMES_VALUE (keyframes, k, p));
+          KEYFRAMES_VALUE (keyframes, k, p) = NULL;
+        }
+    }
   g_free (keyframes->values);
 
   g_slice_free (GtkCssKeyframes, keyframes);
 }
 
-#define KEYFRAMES_VALUE(keyframes, k, p) ((keyframes)->values[(k) * (keyframes)->n_properties + (p)])
-
 static guint
 gtk_css_keyframes_add_keyframe (GtkCssKeyframes *keyframes,
                                 double           progress)



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