Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.85 KB | None | 0 0
  1. From 890b29a57cb1776738dbcada4842182b882a46fd Mon Sep 17 00:00:00 2001
  2. From: Robert Bragg <robert@linux.intel.com>
  3. Date: Wed, 20 Oct 2010 18:26:01 +0100
  4. Subject: [PATCH] actor: re-work unrealize to work with composite actors
  5.  
  6. Unrealizing an actor is a recursive process that needs to traverse the
  7. children of an actor to ensure they are also unrealized. This maintains
  8. the invariant that if any given actor is marked as unrealized then you
  9. know that all its children have also been unrealized.
  10.  
  11. The previous implementation would use the container interface's
  12. foreach_with_internals vfunc to explicitly traverse the children of
  13. container actors but this didn't consider composite actors that aren't
  14. containers.
  15.  
  16. Since clutter-actor now maintains an explicit list of children we can
  17. also handle composite actors that aren't containers using
  18. _clutter_actor_traverse.
  19. ---
  20. clutter/clutter-actor.c | 57 +++++++++++++++++++++++++++-------------------
  21. 1 files changed, 33 insertions(+), 24 deletions(-)
  22.  
  23. diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c
  24. index 070323e..f1da940 100644
  25. --- a/clutter/clutter-actor.c
  26. +++ b/clutter/clutter-actor.c
  27. @@ -1408,11 +1408,6 @@ clutter_actor_real_unrealize (ClutterActor *self)
  28. {
  29. /* we must be unmapped (implying our children are also unmapped) */
  30. g_assert (!CLUTTER_ACTOR_IS_MAPPED (self));
  31. -
  32. - if (CLUTTER_IS_CONTAINER (self))
  33. - clutter_container_foreach_with_internals (CLUTTER_CONTAINER (self),
  34. - CLUTTER_CALLBACK (clutter_actor_unrealize_not_hiding),
  35. - NULL);
  36. }
  37.  
  38. /**
  39. @@ -1466,6 +1461,34 @@ clutter_actor_unrealize (ClutterActor *self)
  40. clutter_actor_unrealize_not_hiding (self);
  41. }
  42.  
  43. +static ClutterActorTraverseVisitFlags
  44. +unrealize_actor_before_children_cb (ClutterActor *self,
  45. + int depth,
  46. + void *user_data)
  47. +{
  48. + /* If an actor is already unrealized we know its children have also
  49. + * already been unrealized... */
  50. + if (!CLUTTER_ACTOR_IS_REALIZED (self))
  51. + return CLUTTER_ACTOR_TRAVERSE_VISIT_SKIP_CHILDREN;
  52. +
  53. + g_signal_emit (self, actor_signals[UNREALIZE], 0);
  54. +
  55. + return CLUTTER_ACTOR_TRAVERSE_VISIT_CONTINUE;
  56. +}
  57. +
  58. +static ClutterActorTraverseVisitFlags
  59. +unrealize_actor_after_children_cb (ClutterActor *self,
  60. + int depth,
  61. + void *user_data)
  62. +{
  63. + /* We want to unset the realized flag only _after_
  64. + * child actors are unrealized, to maintain invariants.
  65. + */
  66. + CLUTTER_ACTOR_UNSET_FLAGS (self, CLUTTER_ACTOR_REALIZED);
  67. + _clutter_notify_by_pspec (G_OBJECT (self), obj_props[PROP_REALIZED]);
  68. + return CLUTTER_ACTOR_TRAVERSE_VISIT_CONTINUE;
  69. +}
  70. +
  71. /*
  72. * clutter_actor_unrealize_not_hiding:
  73. * @self: A #ClutterActor
  74. @@ -1493,25 +1516,11 @@ clutter_actor_unrealize (ClutterActor *self)
  75. static void
  76. clutter_actor_unrealize_not_hiding (ClutterActor *self)
  77. {
  78. - /* All callers of clutter_actor_unrealize_not_hiding() should have
  79. - * taken care of unmapping the actor first. This means
  80. - * all our children should also be unmapped.
  81. - */
  82. - g_assert (!CLUTTER_ACTOR_IS_MAPPED (self));
  83. -
  84. - if (!CLUTTER_ACTOR_IS_REALIZED (self))
  85. - return;
  86. -
  87. - /* The default handler for the signal should recursively unrealize
  88. - * child actors. We want to unset the realized flag only _after_
  89. - * child actors are unrealized, to maintain invariants.
  90. - */
  91. -
  92. - g_signal_emit (self, actor_signals[UNREALIZE], 0);
  93. -
  94. - CLUTTER_ACTOR_UNSET_FLAGS (self, CLUTTER_ACTOR_REALIZED);
  95. -
  96. - _clutter_notify_by_pspec (G_OBJECT (self), obj_props[PROP_REALIZED]);
  97. + _clutter_actor_traverse (self,
  98. + CLUTTER_ACTOR_TRAVERSE_DEPTH_FIRST,
  99. + unrealize_actor_before_children_cb,
  100. + unrealize_actor_after_children_cb,
  101. + NULL);
  102. }
  103.  
  104. /*
  105. --
  106. 1.7.0.4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement