Fix a bug in control background setting 52/106452/1
authorXiangyin Ma <x1.ma@samsung.com>
Wed, 21 Dec 2016 14:47:07 +0000 (14:47 +0000)
committerXiangyin Ma <x1.ma@samsung.com>
Wed, 21 Dec 2016 14:47:07 +0000 (14:47 +0000)
Change-Id: I25eef3eff01496eb28ac12be79443e783fb09168

dali-toolkit/public-api/controls/control-impl.cpp

index e9a866e..e0e1383 100644 (file)
@@ -460,12 +460,16 @@ Vector4 Control::GetBackgroundColor() const
 void Control::SetBackground( const Property::Map& map )
 {
   Actor self( Self() );
-  Toolkit::Visual::Base backgroundVisual;
-  InitializeVisual( self, backgroundVisual, map );
+  Toolkit::Visual::Base backgroundVisual = Toolkit::VisualFactory::Get().CreateVisual( map );
 
   // if new visual created, replace existing one
   if( backgroundVisual )
   {
+    if( self.OnStage() )
+    {
+      mImpl->mBackgroundVisual.RemoveAndReset( self );
+      backgroundVisual.SetOnStage( self );
+    }
     mImpl->mBackgroundVisual = backgroundVisual;
     mImpl->mBackgroundVisual.SetDepthIndex( DepthIndex::BACKGROUND );
   }