[StButton] Hold ref to self until animation completes
StButton has an internal animation for the border-image actor, then it connects to the "completed" signal passing itself as data. However, if the button is destroyed, nothing prevents the animation's completed signal from then causing a reference to freed memory. Holding a reference to the button is the most straightforward fix here. https://bugzilla.gnome.org/show_bug.cgi?id=607825
This commit is contained in:
parent
2aa305b51d
commit
d7e0051bc6
@ -75,6 +75,7 @@ struct _StButtonPrivate
|
|||||||
|
|
||||||
ClutterActor *old_bg;
|
ClutterActor *old_bg;
|
||||||
gboolean old_bg_parented; /* TRUE if we have adopted old_bg */
|
gboolean old_bg_parented; /* TRUE if we have adopted old_bg */
|
||||||
|
gboolean old_bg_animating; /* TRUE if the opacity animation is running and we hold a self-ref */
|
||||||
|
|
||||||
guint8 old_opacity;
|
guint8 old_opacity;
|
||||||
|
|
||||||
@ -122,6 +123,11 @@ st_button_dispose_old_bg (StButton *button)
|
|||||||
}
|
}
|
||||||
g_object_unref (priv->old_bg);
|
g_object_unref (priv->old_bg);
|
||||||
priv->old_bg = NULL;
|
priv->old_bg = NULL;
|
||||||
|
if (priv->old_bg_animating)
|
||||||
|
{
|
||||||
|
g_object_unref (button);
|
||||||
|
priv->old_bg_animating = FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,6 +186,13 @@ st_button_style_changed (StWidget *widget)
|
|||||||
priv->transition_duration,
|
priv->transition_duration,
|
||||||
"opacity", 0,
|
"opacity", 0,
|
||||||
NULL);
|
NULL);
|
||||||
|
/* The reference counting here is looped; through the button, old_bg,
|
||||||
|
* and the animation. However, that's not a problem because we will
|
||||||
|
* break the cycle when either the animation completes, or when
|
||||||
|
* we dispose.
|
||||||
|
*/
|
||||||
|
priv->old_bg_animating = TRUE;
|
||||||
|
g_object_ref (button);
|
||||||
g_signal_connect (animation, "completed",
|
g_signal_connect (animation, "completed",
|
||||||
G_CALLBACK (st_animation_completed), button);
|
G_CALLBACK (st_animation_completed), button);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user