TextVisual - Fix a memory leak issue. 94/93294/2
authorVictor Cebollada <v.cebollada@samsung.com>
Fri, 21 Oct 2016 12:49:47 +0000 (13:49 +0100)
committerVictor Cebollada <v.cebollada@samsung.com>
Fri, 21 Oct 2016 14:05:49 +0000 (15:05 +0100)
Change-Id: I06def29578a38fabdffc226fb774056bbc52fe1b
Signed-off-by: Victor Cebollada <v.cebollada@samsung.com>
dali-toolkit/internal/visuals/text/text-visual.cpp
dali-toolkit/internal/visuals/text/text-visual.h

index 48f9a04..31dc8bb 100644 (file)
@@ -810,6 +810,13 @@ Dali::Property::Value TextVisual::DoGetProperty( Dali::Property::Index index )
 
 void TextVisual::RenderText()
 {
+  Actor self = mSelf.GetHandle();
+  if( !self )
+  {
+    // Nothing to do if the handle is not initialized.
+    return;
+  }
+
   Actor renderableActor;
 
   if( mRenderer )
@@ -826,7 +833,7 @@ void TextVisual::RenderText()
       const Vector2& scrollOffset = mController->GetScrollPosition();
       renderableActor.SetPosition( scrollOffset.x, scrollOffset.y );
 
-      mSelf.Add( renderableActor );
+      self.Add( renderableActor );
     }
     mRenderableActor = renderableActor;
 
@@ -847,6 +854,13 @@ void TextVisual::StopTextAutoScrolling()
 
 void TextVisual::SetUpAutoScrolling()
 {
+  Actor self = mSelf.GetHandle();
+  if( !self )
+  {
+    // Nothing to do if the handle is not initialized.
+    return;
+  }
+
   const Text::ScrollerData* const data = mController->GetAutoScrollData();
 
   if( NULL != data )
@@ -860,8 +874,8 @@ void TextVisual::SetUpAutoScrolling()
     mTextScroller->StartScrolling( mRenderableActor,
                                    *data );
 
-    mSelf.Add( mTextScroller->GetScrollingText() );
-    mSelf.Add( mTextScroller->GetSourceCamera() );
+    self.Add( mTextScroller->GetScrollingText() );
+    self.Add( mTextScroller->GetSourceCamera() );
   }
 }
 
index a57ddba..47289d1 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 // EXTERNAL INCLUDES
+#include <dali/devel-api/object/weak-handle.h>
 #include <dali/public-api/common/intrusive-ptr.h>
 
 // INTERNAL INCLUDES
@@ -168,7 +169,7 @@ private:
 
 private:
   Text::ControllerPtr          mController;               ///< The text's controller.
-  Actor                        mSelf;
+  WeakHandle<Actor>            mSelf;
 
   Text::RendererPtr            mRenderer;
   Text::TextScrollerPtr        mTextScroller;