Commit 39f4848b authored by Neil Roberts's avatar Neil Roberts

Fix some *_set functions so they work if the object is the same value

Bug 1392 - behaviour_set_alpha set same alpha twice lead to warning
and destroy the input alpha

The following functions are fixed:

clutter_actor_set_shader
clutter_alpha_set_timeline
clutter_behaviour_set_alpha
clutter_clone_texture_set_parent_texture

They either now reference the new value before destroying the old
value, or just return immediately if the values are the same.
parent 62cfc648
......@@ -7224,11 +7224,11 @@ clutter_actor_set_shader (ClutterActor *self,
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), FALSE);
g_return_val_if_fail (shader == NULL || CLUTTER_IS_SHADER (shader), FALSE);
/* if shader passed in is NULL we destroy the shader */
if (shader == NULL)
{
destroy_shader_data (self);
}
if (shader)
g_object_ref (shader);
else
/* if shader passed in is NULL we destroy the shader */
destroy_shader_data (self);
actor_priv = self->priv;
shader_data = actor_priv->shader_data;
......@@ -7242,15 +7242,9 @@ clutter_actor_set_shader (ClutterActor *self,
shader_value_free);
}
if (shader_data->shader)
{
g_object_unref (shader_data->shader);
shader_data->shader = NULL;
}
g_object_unref (shader_data->shader);
if (shader)
{
shader_data->shader = g_object_ref (shader);
}
shader_data->shader = shader;
if (CLUTTER_ACTOR_IS_VISIBLE (self))
clutter_actor_queue_redraw (self);
......
......@@ -395,6 +395,9 @@ clutter_alpha_set_timeline (ClutterAlpha *alpha,
priv = alpha->priv;
if (priv->timeline == timeline)
return;
if (priv->timeline)
{
g_signal_handlers_disconnect_by_func (priv->timeline,
......
......@@ -570,6 +570,9 @@ clutter_behaviour_set_alpha (ClutterBehaviour *behave,
priv = behave->priv;
if (alpha)
g_object_ref_sink (alpha);
if (priv->notify_id)
{
CLUTTER_NOTE (BEHAVIOUR, "removing previous notify-id (%d)",
......@@ -590,7 +593,6 @@ clutter_behaviour_set_alpha (ClutterBehaviour *behave,
if (alpha)
{
priv->alpha = alpha;
g_object_ref_sink (priv->alpha);
priv->notify_id = g_signal_connect (priv->alpha, "notify::alpha",
G_CALLBACK(notify_cb),
......
......@@ -221,6 +221,9 @@ set_parent_texture (ClutterCloneTexture *ctexture,
ClutterActor *actor = CLUTTER_ACTOR (ctexture);
gboolean was_visible = CLUTTER_ACTOR_IS_VISIBLE (ctexture);
if (priv->parent_texture == texture)
return;
if (priv->parent_texture)
{
g_object_unref (priv->parent_texture);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment