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.
This commit is contained in:
Cosimo Cecchi 2012-10-16 11:52:59 -04:00
parent 6fb66261ca
commit 97f49c681b

View File

@ -36,6 +36,8 @@ struct _GtkCssKeyframes {
GtkCssValue **values; /* 2D array: n_keyframes * n_properties of (value or NULL) for all the keyframes */ 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 * GtkCssKeyframes *
_gtk_css_keyframes_ref (GtkCssKeyframes *keyframes) _gtk_css_keyframes_ref (GtkCssKeyframes *keyframes)
{ {
@ -49,6 +51,8 @@ _gtk_css_keyframes_ref (GtkCssKeyframes *keyframes)
void void
_gtk_css_keyframes_unref (GtkCssKeyframes *keyframes) _gtk_css_keyframes_unref (GtkCssKeyframes *keyframes)
{ {
guint k, p;
g_return_if_fail (keyframes != NULL); g_return_if_fail (keyframes != NULL);
keyframes->ref_count--; keyframes->ref_count--;
@ -57,13 +61,20 @@ _gtk_css_keyframes_unref (GtkCssKeyframes *keyframes)
g_free (keyframes->keyframe_progress); g_free (keyframes->keyframe_progress);
g_free (keyframes->property_ids); 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_free (keyframes->values);
g_slice_free (GtkCssKeyframes, keyframes); g_slice_free (GtkCssKeyframes, keyframes);
} }
#define KEYFRAMES_VALUE(keyframes, k, p) ((keyframes)->values[(k) * (keyframes)->n_properties + (p)])
static guint static guint
gtk_css_keyframes_add_keyframe (GtkCssKeyframes *keyframes, gtk_css_keyframes_add_keyframe (GtkCssKeyframes *keyframes,
double progress) double progress)