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



commit 36528d3af06e88ac07a4721f416d9447855b2643
Author: Neil Roberts <neil linux intel com>
Date:   Tue Apr 5 17:30:29 2011 +0100

    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

 clutter/cogl/cogl/cogl-pipeline.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/clutter/cogl/cogl/cogl-pipeline.c b/clutter/cogl/cogl/cogl-pipeline.c
index 76d02ac..acce536 100644
--- a/clutter/cogl/cogl/cogl-pipeline.c
+++ b/clutter/cogl/cogl/cogl-pipeline.c
@@ -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;



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