From d444e5f35f1fda1faa38b1e6081f2ab69d58d7c0 Mon Sep 17 00:00:00 2001 From: Xiangyin Ma Date: Mon, 21 Mar 2016 18:01:24 +0000 Subject: [PATCH] Always notify the derived class when removing child actor Change-Id: Id8e1276ab9f615aacd5cce5422e02a71099a3066 --- automated-tests/src/dali/utc-Dali-CustomActor.cpp | 12 ++++++++---- dali/internal/event/actors/actor-impl.cpp | 6 +++--- dali/internal/event/actors/actor-impl.h | 2 +- dali/public-api/actors/custom-actor-impl.h | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/automated-tests/src/dali/utc-Dali-CustomActor.cpp b/automated-tests/src/dali/utc-Dali-CustomActor.cpp index aca2c62..928500d 100644 --- a/automated-tests/src/dali/utc-Dali-CustomActor.cpp +++ b/automated-tests/src/dali/utc-Dali-CustomActor.cpp @@ -1567,17 +1567,21 @@ int UtcDaliCustomActorRemoveDuringOnChildRemove(void) DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION ); // The actorB added to actorA // mContainer will then receive OnChildAdd - DALI_TEST_EQUALS( 2, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION ); + DALI_TEST_EQUALS( 3, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION ); DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION ); - DALI_TEST_EQUALS( "OnChildAdd", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION ); + // The derived class are always notified, no matter the child is successfully removed or not + DALI_TEST_EQUALS( "OnChildRemove", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "OnChildAdd", actorB.GetMethodsCalled()[ 2 ], TEST_LOCATION ); - DALI_TEST_EQUALS( 5, (int)(MasterCallStack.size()), TEST_LOCATION ); + DALI_TEST_EQUALS( 6, (int)(MasterCallStack.size()), TEST_LOCATION ); DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 0 ], TEST_LOCATION ); DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION ); DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION ); DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 3 ], TEST_LOCATION ); - DALI_TEST_EQUALS( "ActorB: OnChildAdd", MasterCallStack[ 4 ], TEST_LOCATION ); + // The derived class are always notified, no matter the child is successfully removed or not + DALI_TEST_EQUALS( "ActorB: OnChildRemove", MasterCallStack[ 4 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "ActorB: OnChildAdd", MasterCallStack[ 5 ], TEST_LOCATION ); // Excercise the message passing to Update thread diff --git a/dali/internal/event/actors/actor-impl.cpp b/dali/internal/event/actors/actor-impl.cpp index 95bf894..7828b77 100644 --- a/dali/internal/event/actors/actor-impl.cpp +++ b/dali/internal/event/actors/actor-impl.cpp @@ -461,15 +461,15 @@ void Actor::Remove( Actor& child ) if( removed ) { - // Notification for derived classes - OnChildRemove( *(removed.Get()) ); - // Only put in a relayout request if there is a suitable dependency if( RelayoutDependentOnChildren() ) { RelayoutRequest(); } } + + // Notification for derived classes + OnChildRemove( child ); } void Actor::Unparent() diff --git a/dali/internal/event/actors/actor-impl.h b/dali/internal/event/actors/actor-impl.h index 1ff3035..ccf2644 100644 --- a/dali/internal/event/actors/actor-impl.h +++ b/dali/internal/event/actors/actor-impl.h @@ -1731,7 +1731,7 @@ private: } /** - * For use in derived classes; this is called after Remove() has removed a child. + * For use in derived classes; this is called after Remove() has attempted to remove a child( regardless of whether it succeeded or not ). * @param[in] child The child that was removed. */ virtual void OnChildRemove( Actor& child ) diff --git a/dali/public-api/actors/custom-actor-impl.h b/dali/public-api/actors/custom-actor-impl.h index 975d4fe..2f3e256 100644 --- a/dali/public-api/actors/custom-actor-impl.h +++ b/dali/public-api/actors/custom-actor-impl.h @@ -137,7 +137,7 @@ public: virtual void OnChildAdd(Actor& child) = 0; /** - * @brief Called after a child has been removed from the owning actor. + * @brief Called after the owning actor has attempted to remove a child( regardless of whether it succeeded or not ). * * @SINCE_1_0.0 * @param[in] child The child being removed -- 2.7.4