Always notify the derived class when removing child actor 30/63030/5
authorXiangyin Ma <x1.ma@samsung.com>
Mon, 21 Mar 2016 18:01:24 +0000 (18:01 +0000)
committerXiangyin Ma <x1.ma@samsung.com>
Tue, 29 Mar 2016 13:27:55 +0000 (06:27 -0700)
Change-Id: Id8e1276ab9f615aacd5cce5422e02a71099a3066

automated-tests/src/dali/utc-Dali-CustomActor.cpp
dali/internal/event/actors/actor-impl.cpp
dali/internal/event/actors/actor-impl.h
dali/public-api/actors/custom-actor-impl.h

index aca2c62..928500d 100644 (file)
@@ -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
 
index 95bf894..7828b77 100644 (file)
@@ -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()
index 1ff3035..ccf2644 100644 (file)
@@ -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 )
index 975d4fe..2f3e256 100644 (file)
@@ -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