[clutter] Avoid crashing when an actor not parented to a toplevel is cloned



commit 76c8cd292ed269bd75e7482d96fd4209076d2266
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Tue Sep 29 14:15:16 2015 -0400

    Avoid crashing when an actor not parented to a toplevel is cloned
    
    If we can't realize the source actor for a clone, simply skip updating
    the map state and painting it.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=745517

 clutter/clutter-actor.c |    6 +++++-
 clutter/clutter-clone.c |   12 +++++++++---
 2 files changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c
index ad106c4..53c1354 100644
--- a/clutter/clutter-actor.c
+++ b/clutter/clutter-actor.c
@@ -15938,7 +15938,11 @@ _clutter_actor_set_enable_paint_unmapped (ClutterActor *self,
        */
       clutter_actor_realize (self);
 
-      clutter_actor_update_map_state (self, MAP_STATE_MAKE_MAPPED);
+      /* If the actor isn't ultimately connected to a toplevel, it can't be
+       * realized or painted.
+       */
+      if (CLUTTER_ACTOR_IS_REALIZED (self))
+          clutter_actor_update_map_state (self, MAP_STATE_MAKE_MAPPED);
     }
   else
     {
diff --git a/clutter/clutter-clone.c b/clutter/clutter-clone.c
index a84c7fe..eb91915 100644
--- a/clutter/clutter-clone.c
+++ b/clutter/clutter-clone.c
@@ -184,9 +184,15 @@ clutter_clone_paint (ClutterActor *actor)
       was_unmapped = TRUE;
     }
 
-  _clutter_actor_push_clone_paint ();
-  clutter_actor_paint (priv->clone_source);
-  _clutter_actor_pop_clone_paint ();
+  /* If the source isn't ultimately parented to a toplevel, it can't be
+   * realized or painted.
+   */
+  if (clutter_actor_is_realized (priv->clone_source))
+    {
+      _clutter_actor_push_clone_paint ();
+      clutter_actor_paint (priv->clone_source);
+      _clutter_actor_pop_clone_paint ();
+    }
 
   if (was_unmapped)
     _clutter_actor_set_enable_paint_unmapped (priv->clone_source, FALSE);


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