Visual replacements logic updated 42/137142/9
authorAgnelo Vaz <agnelo.vaz@samsung.com>
Mon, 3 Jul 2017 14:32:22 +0000 (15:32 +0100)
committerAgnelo Vaz <agnelo.vaz@samsung.com>
Tue, 11 Jul 2017 16:38:29 +0000 (17:38 +0100)
Setting conrol off stage ensures correct visuals shown when returned on stage
Ensure Control relayout is requested when a Visual becomes ready
Add flag to know if registered visual is pending ( can help relayouting )
Update of replacement logic

Change-Id: Id6cde8dc6a006d48155274c77210e3bb494e1765

automated-tests/src/dali-toolkit/utc-Dali-PushButton.cpp
automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp
dali-toolkit/internal/controls/control/control-data-impl.cpp
dali-toolkit/internal/controls/control/control-data-impl.h
dali-toolkit/internal/controls/image-view/image-view-impl.cpp
dali-toolkit/public-api/controls/control-impl.cpp

index 57b39a5..7ea83bc 100644 (file)
@@ -48,6 +48,7 @@ void utc_dali_toolkit_pushbutton_cleanup(void)
 namespace
 {
 static const char* TEST_IMAGE_ONE = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
+static const char* TEST_IMAGE_TWO = TEST_RESOURCE_DIR "/icon-delete.jpg";
 
 static const Vector2 INSIDE_TOUCH_POINT_POSITON  = Vector2( 240, 400 );
 static const Vector3 BUTTON_POSITON_TO_GET_INSIDE_TOUCH_EVENTS  = Vector3( 200, 360, 0 );
@@ -1816,3 +1817,37 @@ int UtcDaliPushButtonSetDisabledSelectedImageWithActorDeprecatedP(void)
 
   END_TEST;
 }
+
+int UtcDaliPushButtonReplaceButtonImageP2(void)
+{
+  tet_infoline("Set button image then replace with new image and query url");
+
+  ToolkitTestApplication application;
+
+  ResourceImage setImage = ResourceImage::New( TEST_IMAGE_ONE );
+  DALI_TEST_CHECK(setImage);
+
+  Actor imgActorSet = ImageView::New(setImage);
+  DALI_TEST_CHECK(imgActorSet);
+
+  PushButton pushButton = PushButton::New();
+  pushButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, TEST_IMAGE_TWO );
+
+
+  Stage::GetCurrent().Add( pushButton );
+
+  pushButton.SetButtonImage( imgActorSet );
+  application.SendNotification();
+  application.Render();
+
+  tet_infoline("Get button image before it has been able to load");
+
+  ImageView imageView = ImageView::DownCast(pushButton.GetButtonImage());
+
+  ResourceImage getImage = ResourceImage::DownCast( imageView.GetImage() );
+
+  tet_infoline("Check if url matches last assignment even if not loaded yet");
+  DALI_TEST_EQUALS( getImage.GetUrl(), setImage.GetUrl() , TEST_LOCATION );
+
+  END_TEST;
+}
index f441dd8..f8e61b8 100644 (file)
@@ -24,6 +24,7 @@
 #include <dali/public-api/rendering/shader.h>
 #include <dali/devel-api/object/handle-devel.h>
 #include <dali-toolkit/devel-api/controls/control-devel.h>
+#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
 #include <dali-toolkit/devel-api/visual-factory/transition-data.h>
 #include <dali-toolkit/devel-api/visuals/text-visual-properties.h>
@@ -2142,6 +2143,42 @@ int UtcDaliRegisterVisualOrder(void)
   END_TEST;
 }
 
+int UtcDaliRegisterVisualOrder02(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline( "Register Visual Order with Background Set" );
+
+  DummyControl dummyControl = DummyControl::New(true);
+  Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
+
+  const int backgroundDepthIndex = Toolkit::DepthIndex::BACKGROUND;
+
+  VisualFactory factory = VisualFactory::Get();
+  Property::Map propertyMap;
+  propertyMap.Insert(Visual::Property::TYPE,  Visual::COLOR);
+  propertyMap.Insert(ColorVisual::Property::MIX_COLOR,  Color::BLUE);
+
+  tet_printf( "Register a control background visual, should have depth index of %d\n", backgroundDepthIndex );
+
+  dummyControl.SetProperty( Control::Property::BACKGROUND, propertyMap );
+
+  const int TEST_VISUAL_1_DEPTH_INDEX = 0;
+  tet_printf( "Register visual, should have depth index of %d\n", TEST_VISUAL_1_DEPTH_INDEX );
+  Visual::Base testVisual1 = factory.CreateVisual( propertyMap );
+  dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, testVisual1 );
+  DALI_TEST_EQUALS( testVisual1.GetDepthIndex(), TEST_VISUAL_1_DEPTH_INDEX , TEST_LOCATION );
+
+  tet_printf( "Register another visual, should have a depth index greater than previous(%d)\n", TEST_VISUAL_1_DEPTH_INDEX );
+  Visual::Base testVisual2 = factory.CreateVisual( propertyMap );
+  dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL2, testVisual2 );
+  DALI_TEST_CHECK( testVisual2.GetDepthIndex() >  testVisual1.GetDepthIndex() );
+
+  dummyControl.SetSize(200.f, 200.f);
+  Stage::GetCurrent().Add( dummyControl );
+
+  END_TEST;
+}
+
 int UtcDaliRegisterVisualWithDepthIndex(void)
 {
   ToolkitTestApplication application;
index a5e4b98..2469beb 100644 (file)
@@ -275,6 +275,24 @@ TypeAction registerAction( typeRegistration, ACTION_ACCESSIBILITY_ACTIVATED, &Do
 
 DALI_TYPE_REGISTRATION_END()
 
+/**
+ * @brief Iterate through given container and setOffStage any visual found
+ *
+ * @param[in] container Container of visuals
+ * @param[in] parent Parent actor to remove visuals from
+ */
+void SetVisualsOffStage( const RegisteredVisualContainer& container, Actor parent )
+{
+  for( auto iter = container.Begin(), end = container.End() ; iter!= end; iter++)
+  {
+    if( (*iter)->visual )
+    {
+      DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::SetOffStage Setting visual(%d) off stage\n", (*iter)->index );
+      Toolkit::GetImplementation((*iter)->visual).SetOffStage( parent );
+    }
+  }
+}
+
 } // unnamed namespace
 
 
@@ -354,80 +372,6 @@ void Control::Impl::LongPressDetected(Actor actor, const LongPressGesture& longP
   mControlImpl.OnLongPress(longPress);
 }
 
-// Called by a Visual when it's resource is ready
-void Control::Impl::ResourceReady( Visual::Base& object)
-{
-  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "ResourceReady \n");
-
-  // A resource is ready, check if is in the replacement visual container
-  // Iterate through all visuals in replacement container and store indexes of ready visuals
-  Dali::Vector <Property::Index> readyVisuals;
-  Actor self = mControlImpl.Self();
-
-  for( auto replacementVisualIter = mReplacementVisuals.Begin();
-        replacementVisualIter < mReplacementVisuals.End(); ++replacementVisualIter )
-  {
-    const Toolkit::Visual::Base replacementVisual = (*replacementVisualIter)->visual;
-    const Internal::Visual::Base& replacementVisualImpl = Toolkit::GetImplementation( replacementVisual );
-
-    if( replacementVisualImpl.IsResourceReady() )
-    {
-      // Check if new replacement visual (index) is already queued for replacement and swap old for new.
-      RegisteredVisualContainer::Iterator registeredVisualsIter;
-      if( FindVisual( (*replacementVisualIter)->index, mVisuals, registeredVisualsIter ) )
-      {
-        Property::Index readyVisualIndex = (*replacementVisualIter)->index;
-        DALI_LOG_INFO( gLogFilter, Debug::Verbose, "ResourceReady: %d Ready to replace\n", readyVisualIndex );
-        readyVisuals.PushBack( readyVisualIndex );
-        // Remove current shown visual from stage and from registered visuals container
-        Toolkit::GetImplementation((*registeredVisualsIter)->visual).SetOffStage( self );
-        mVisuals.Erase( registeredVisualsIter );
-      }
-    }
-  }
-
-  for( auto readyVisualsIter = readyVisuals.Begin(); readyVisualsIter != readyVisuals.End(); readyVisualsIter++ )
-  {
-    DALI_LOG_INFO( gLogFilter, Debug::Verbose, "ResourceReady: %d Matched\n", (*readyVisualsIter) );
-    // Move new visual to be shown from replacement container into the control's registered visuals container
-    // Replacement visual has already been set on stage when it was added to replacement container
-    RegisteredVisualContainer::Iterator readyReplacementVisual;
-    if( FindVisual( (*readyVisualsIter) , mReplacementVisuals, readyReplacementVisual ) )
-    {
-      MoveVisual( readyReplacementVisual, mReplacementVisuals, mVisuals ); // Erases visual from replacement queue
-    }
-    // A visual has been replaced so control will most likely need relayouting
-    mControlImpl.RelayoutRequest();
-  }
-
-  // Emit signal if all enabled visuals registered by the control are ready.
-  // If any visual is registered and enabled but not ready then the control will not be able to emit ReadySignal.
-
-  if ( IsResourceReady() )
-  {
-    Dali::Toolkit::Control handle( mControlImpl.GetOwner() );
-    mResourceReadySignal.Emit( handle );
-  }
-}
-
-bool Control::Impl::IsResourceReady() const
-{
-  // Iterate through and check all the enabled visuals are ready
-  for ( auto visualIter = mVisuals.Begin();
-         visualIter != mVisuals.End(); ++visualIter )
-  {
-    const Toolkit::Visual::Base visual = (*visualIter)->visual;
-    const Internal::Visual::Base& visualImpl = Toolkit::GetImplementation( visual );
-
-    // one of the enabled visuals is not ready
-    if( !visualImpl.IsResourceReady() && (*visualIter)->enabled )
-    {
-      return false;
-    }
-  }
-  return true;
-}
-
 void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual )
 {
   RegisterVisual( index, visual, VisualState::ENABLED, DepthIndexValue::NOT_SET );
@@ -455,48 +399,61 @@ void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base
   bool visualReplaced ( false );
   Actor self = mControlImpl.Self();
 
+  // Set the depth index, if not set by caller this will be either the current visual depth, max depth of all visuals
+  // or zero.
+  int requiredDepthIndex = visual.GetDepthIndex();
+
+  if( depthIndexValueSet == DepthIndexValue::SET )
+  {
+    requiredDepthIndex = depthIndex;
+  }
+
+  // Visual replacement, existing visual should only be removed from stage when replacement ready.
   if( !mVisuals.Empty() )
   {
     RegisteredVisualContainer::Iterator registeredVisualsiter;
-    // Check if visual (index) is already registered.  Replace if so.
+    // Check if visual (index) is already registered, this is the current visual.
     if( FindVisual( index, mVisuals, registeredVisualsiter ) )
     {
-      if( (*registeredVisualsiter)->visual )
+      Toolkit::Visual::Base& currentRegisteredVisual = (*registeredVisualsiter)->visual;
+      if( currentRegisteredVisual )
       {
         // Store current visual depth index as may need to set the replacement visual to same depth
         const int currentDepthIndex = (*registeredVisualsiter)->visual.GetDepthIndex();
 
-        // Monitor when the visuals resources are ready
-        StopObservingVisual( (*registeredVisualsiter)->visual );
-        StartObservingVisual( visual );
+        // No longer required to know if the replaced visual's resources are ready
+        StopObservingVisual( currentRegisteredVisual );
 
-        if(  self.OnStage() )
+        // If control staged and visual enabled then visuals will be swapped once ready
+        if(  self.OnStage() && enabled )
         {
-          DALI_LOG_INFO( gLogFilter, Debug::Verbose, "RegisterVisual Adding visual to replacement Queue: %d \n", index );
-          // Check if visual is currently in the process of being replaced
-          RegisteredVisualContainer::Iterator queuedReplacementVisual;
-          if ( FindVisual( index, mReplacementVisuals, queuedReplacementVisual ) )
+          // Check if visual is currently in the process of being replaced ( is in removal container )
+          RegisteredVisualContainer::Iterator visualQueuedForRemoval;
+          if ( FindVisual( index, mRemoveVisuals, visualQueuedForRemoval ) )
+          {
+            // Visual with same index is already in removal container so current visual pending
+            // Only the the last requested visual will be displayed so remove current visual which is staged but not ready.
+            Toolkit::GetImplementation( currentRegisteredVisual ).SetOffStage( self );
+            mVisuals.Erase( registeredVisualsiter );
+          }
+          else
           {
-            // If visual on replacement queue is going to be replaced before it's ready then will be removed from queue (and stage)
-            // Only the the last requested visual will be queued and then displayed.
-            Toolkit::GetImplementation( (*queuedReplacementVisual)->visual ).SetOffStage( self );
-            mReplacementVisuals.Erase(queuedReplacementVisual);
+            // current visual not already in removal container so add now.
+            DALI_LOG_INFO( gLogFilter, Debug::Verbose, "RegisterVisual Move current registered visual to removal Queue: %d \n", index );
+            MoveVisual( registeredVisualsiter, mVisuals, mRemoveVisuals );
           }
-          // Add to replacement list
-          mReplacementVisuals.PushBack( new RegisteredVisual( index, visual, ( enabled == VisualState::ENABLED ? true : false ) ) );
         }
         else
         {
-          // Not staged so can just replace registered visual
-          (*registeredVisualsiter)->visual = visual;
-          (*registeredVisualsiter)->enabled = ( enabled == VisualState::ENABLED ) ? true : false;
+          // Control not staged or visual disabled so can just erase from registered visuals and new visual will be added later.
+          mVisuals.Erase( registeredVisualsiter );
         }
 
         // If we've not set the depth-index value and the new visual does not have a depth index applied to it, then use the previously set depth-index for this index
         if( ( depthIndexValueSet == DepthIndexValue::NOT_SET ) &&
             ( visual.GetDepthIndex() == 0 ) )
         {
-          visual.SetDepthIndex( currentDepthIndex );
+          requiredDepthIndex = currentDepthIndex;
         }
       }
 
@@ -526,15 +483,12 @@ void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base
 
   if( !visualReplaced ) // New registration entry
   {
-    DALI_LOG_INFO( gLogFilter, Debug::Concise, "New Visual registration %d\n", index);
-    mVisuals.PushBack( new RegisteredVisual( index, visual, ( enabled == VisualState::ENABLED ? true : false ) ) );
-
-    // monitor when the visuals resources are ready
+    // monitor when the visual resources are ready
     StartObservingVisual( visual );
 
     // If we've not set the depth-index value, we have more than one visual and the visual does not have a depth index, then set it to be the highest
     if( ( depthIndexValueSet == DepthIndexValue::NOT_SET ) &&
-        ( mVisuals.Size() > 1 ) &&
+        ( mVisuals.Size() > 0 ) &&
         ( visual.GetDepthIndex() == 0 ) )
     {
       int maxDepthIndex = std::numeric_limits< int >::min();
@@ -549,29 +503,34 @@ void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base
           maxDepthIndex = visualDepthIndex;
         }
       }
-
       ++maxDepthIndex; // Add one to the current maximum depth index so that our added visual appears on top
-      visual.SetDepthIndex( maxDepthIndex );
+      requiredDepthIndex = std::max( 0, maxDepthIndex ); // Start at zero if maxDepth index belongs to a background
     }
   }
 
   if( visual )
   {
-    // If the caller has set the depth-index, then set it here
-    if( depthIndexValueSet == DepthIndexValue::SET )
-    {
-      visual.SetDepthIndex( depthIndex );
-    }
+    // Set determined depth index
+    visual.SetDepthIndex( requiredDepthIndex );
+
+    // Monitor when the visual resources are ready
+    StartObservingVisual( visual );
+
+    DALI_LOG_INFO( gLogFilter, Debug::Concise, "New Visual registration index[%d] depth[%d]\n", index, requiredDepthIndex );
+    RegisteredVisual* newRegisteredVisual  = new RegisteredVisual( index, visual,
+                                             ( enabled == VisualState::ENABLED ? true : false ),
+                                             ( visualReplaced && enabled ) ) ;
+    mVisuals.PushBack( newRegisteredVisual );
 
     // Put on stage if enabled and the control is already on the stage
+    // Visual must be set on stage for the renderer to be created and the ResourceReady triggered.
     if( ( enabled == VisualState::ENABLED ) && self.OnStage() )
     {
-      // Visual must be set on stage for the renderer to be created and the ResourceReady triggered.
       Toolkit::GetImplementation(visual).SetOnStage( self );
     }
   }
 
-  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::RegisterVisual() Registered %s(%d), enabled:%s\n",  visual.GetName().c_str(), index, enabled?"T":"F" );
+  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::RegisterVisual() Registered %s(%d), enabled:%s\n",  visual.GetName().c_str(), index, enabled?"true":"false" );
 }
 
 void Control::Impl::UnregisterVisual( Property::Index index )
@@ -657,6 +616,65 @@ void Control::Impl::StartObservingVisual( Toolkit::Visual::Base& visual)
   visualImpl.AddResourceObserver( *this );
 }
 
+// Called by a Visual when it's resource is ready
+void Control::Impl::ResourceReady( Visual::Base& object)
+{
+  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "ResourceReady replacements pending[%d]\n", mRemoveVisuals.Count() );
+
+  Actor self = mControlImpl.Self();
+
+  // A resource is ready, find resource in the registered visuals container and get its index
+  for( auto registeredIter = mVisuals.Begin(),  end = mVisuals.End(); registeredIter != end; ++registeredIter )
+  {
+    Internal::Visual::Base& registeredVisualImpl = Toolkit::GetImplementation( (*registeredIter)->visual );
+
+    if( &object == &registeredVisualImpl )
+    {
+      RegisteredVisualContainer::Iterator visualToRemoveIter;
+      // Find visual with the same index in the removal container
+      // Set if off stage as it's replacement is now ready.
+      // Remove if from removal list as now removed from stage.
+      // Set Pending flag on the ready visual to false as now ready.
+      if( FindVisual( (*registeredIter)->index, mRemoveVisuals, visualToRemoveIter ) )
+      {
+        (*registeredIter)->pending = false;
+        Toolkit::GetImplementation( (*visualToRemoveIter)->visual ).SetOffStage( self );
+        mRemoveVisuals.Erase( visualToRemoveIter );
+      }
+      break;
+    }
+  }
+
+  // A visual is ready so control may need relayouting
+  mControlImpl.RelayoutRequest();
+
+  // Emit signal if all enabled visuals registered by the control are ready.
+  if( IsResourceReady() )
+  {
+    Dali::Toolkit::Control handle( mControlImpl.GetOwner() );
+    mResourceReadySignal.Emit( handle );
+  }
+}
+
+bool Control::Impl::IsResourceReady() const
+{
+  // Iterate through and check all the enabled visuals are ready
+  for( auto visualIter = mVisuals.Begin();
+         visualIter != mVisuals.End(); ++visualIter )
+  {
+    const Toolkit::Visual::Base visual = (*visualIter)->visual;
+    const Internal::Visual::Base& visualImpl = Toolkit::GetImplementation( visual );
+
+    // one of the enabled visuals is not ready
+    if( !visualImpl.IsResourceReady() && (*visualIter)->enabled )
+    {
+      return false;
+    }
+  }
+  return true;
+}
+
+
 Dali::Animation Control::Impl::CreateTransition( const Toolkit::TransitionData& handle )
 {
   Dali::Animation transition;
@@ -1254,6 +1272,32 @@ void Control::Impl::SetSubState( const std::string& subStateName, bool withTrans
   }
 }
 
+void Control::Impl::OnStageDisconnection()
+{
+  Actor self = mControlImpl.Self();
+
+  // Any visuals set for replacement but not yet ready should still be registered.
+  // Reason: If a request was made to register a new visual but the control removed from stage before visual was ready
+  // then when this control appears back on stage it should use that new visual.
+
+  // Iterate through all registered visuals and set off stage
+  SetVisualsOffStage( mVisuals, self );
+
+  // Visuals pending replacement can now be taken out of the removal list and set off stage
+  // Iterate through all replacement visuals and add to a move queue then set off stage
+  for( auto removalIter = mRemoveVisuals.Begin(), end = mRemoveVisuals.End(); removalIter != end; removalIter++ )
+  {
+    Toolkit::GetImplementation((*removalIter)->visual).SetOffStage( self );
+  }
+
+  for( auto replacedIter = mVisuals.Begin(), end = mVisuals.End(); replacedIter != end; replacedIter++ )
+  {
+    (*replacedIter)->pending = false;
+  }
+
+  mRemoveVisuals.Clear();
+}
+
 } // namespace Internal
 
 } // namespace Toolkit
index 91b8314..73c4626 100644 (file)
@@ -41,20 +41,21 @@ namespace Toolkit
 namespace Internal
 {
 
-/**
+ /**
   * Struct used to store Visual within the control, index is a unique key for each visual.
   */
- struct RegisteredVisual
- {
-   Property::Index index;
-   Toolkit::Visual::Base visual;
-   bool enabled;
-
-   RegisteredVisual( Property::Index aIndex, Toolkit::Visual::Base &aVisual, bool aEnabled)
-   : index(aIndex), visual(aVisual), enabled(aEnabled)
-   {
-   }
- };
+struct RegisteredVisual
+{
+  Property::Index index;
+  Toolkit::Visual::Base visual;
+  bool enabled : 1;
+  bool pending : 1;
+
+  RegisteredVisual( Property::Index aIndex, Toolkit::Visual::Base &aVisual, bool aEnabled, bool aPendingReplacement )
+  : index(aIndex), visual(aVisual), enabled(aEnabled), pending( aPendingReplacement )
+  {
+  }
+};
 
 typedef Dali::OwnerContainer< RegisteredVisual* > RegisteredVisualContainer;
 
@@ -259,6 +260,11 @@ public:
    */
   bool IsResourceReady() const;
 
+  /**
+   * @copydoc CustomActorImpl::OnStageDisconnection()
+   */
+  void OnStageDisconnection();
+
 private:
 
   /**
@@ -332,7 +338,7 @@ public:
   bool mIsKeyboardNavigationSupported :1;  ///< Stores whether keyboard navigation is supported by the control.
   bool mIsKeyboardFocusGroup :1;           ///< Stores whether the control is a focus group.
 
-  RegisteredVisualContainer mReplacementVisuals;         ///< List of visuals that will be used for replacing current visuals.
+  RegisteredVisualContainer mRemoveVisuals;         ///< List of visuals that are being replaced by another visual once ready
 
   // Properties - these need to be members of Internal::Control::Impl as they access private methods/data of Internal::Control and Internal::Control::Impl.
   static const PropertyRegistration PROPERTY_1;
index 8ced30e..4183b89 100644 (file)
@@ -214,6 +214,9 @@ void ImageView::OnRelayout( const Vector2& size, RelayoutContainer& container )
 {
   Control::OnRelayout( size, container );
 
+  // If visual is being replaced then mVisual will be the replacement visual even if not ready.
+  mVisual = DevelControl::GetVisual( *this, Toolkit::ImageView::Property::IMAGE );
+
   if( mVisual )
   {
     // Pass in an empty map which uses default transform values meaning our visual fills the control
@@ -224,7 +227,6 @@ void ImageView::OnRelayout( const Vector2& size, RelayoutContainer& container )
 
 void ImageView::OnResourceReady( Toolkit::Control control )
 {
-  mVisual = DevelControl::GetVisual( *this, Toolkit::ImageView::Property::IMAGE );
 }
 
 ///////////////////////////////////////////////////////////
index 59e0a18..05f7ab3 100644 (file)
@@ -517,16 +517,7 @@ void Control::OnStageConnection( int depth )
 
 void Control::OnStageDisconnection()
 {
-  for(RegisteredVisualContainer::Iterator iter = mImpl->mVisuals.Begin(); iter!= mImpl->mVisuals.End(); iter++)
-  {
-    // Check whether the visual is empty
-    if( (*iter)->visual )
-    {
-      DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::OnStageDisconnection Setting visual(%d) off stage\n", (*iter)->index );
-      Actor self( Self() );
-      Toolkit::GetImplementation((*iter)->visual).SetOffStage( self );
-    }
-  }
+  mImpl->OnStageDisconnection();
 }
 
 void Control::OnKeyInputFocusGained()