cogl-pipeline: Be careful not to take ownership of root layer

In _cogl_pipeline_prune_empty_layer_difference if the layer's parent
has no owner then it just takes ownership of it. However this could
theoretically end up taking ownership of the root layer because
according to the comment above in the same function that should never
have an owner. This patch just adds an extra check to ensure that the
unowned layer has a parent.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2588
This commit is contained in:
Neil Roberts 2011-04-05 17:30:29 +01:00 committed by Robert Bragg
parent e625be6c96
commit 36528d3af0

View File

@ -2189,9 +2189,11 @@ _cogl_pipeline_prune_empty_layer_difference (CoglPipeline *layers_authority,
/* If the layer's parent doesn't have an owner then we can simply
* take ownership ourselves and drop our reference on the empty
* layer.
* layer. We don't want to take ownership of the root node layer so
* we also need to verify that the parent has a parent
*/
if (layer_parent->index == layer->index && layer_parent->owner == NULL)
if (layer_parent->index == layer->index && layer_parent->owner == NULL &&
_cogl_pipeline_layer_get_parent (layer_parent) != NULL)
{
cogl_object_ref (layer_parent);
layer_parent->owner = layers_authority;