TextVisual - Fix a memory leak issue.
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / text / text-visual.h
index 9151ec7..47289d1 100644 (file)
  *
  */
 
+// EXTERNAL INCLUDES
+#include <dali/devel-api/object/weak-handle.h>
+#include <dali/public-api/common/intrusive-ptr.h>
+
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
 #include <dali-toolkit/internal/text/rendering/text-renderer.h>
@@ -69,19 +73,16 @@ class TextVisual : public Visual::Base
 public:
 
   /**
-   * @brief Constructor.
+   * @brief Create a new text visual.
    *
-   * @param[in] factoryCache The VisualFactoryCache object
+   * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
+   * @return A smart-pointer to the newly allocated visual.
    */
-  TextVisual( VisualFactoryCache& factoryCache );
+  static TextVisualPtr New( VisualFactoryCache& factoryCache );
 
   /**
-   * @brief A reference counted object may only be deleted by calling Unreference().
-   */
-  ~TextVisual();
-
-  /**
-   *
+   * @brief Sets the text control interface which is needed to communicate with a control.
+   * @param[in] controlInterface Pointer to the control-interface.
    */
   void SetTextControlInterface( Text::ControlInterface* controlInterface );
 
@@ -107,11 +108,26 @@ public: // from Visual::Base
    */
   virtual void DoCreatePropertyMap( Property::Map& map ) const;
 
-protected: // from Visual::Base
+protected:
+
+  /**
+   * @brief Constructor.
+   *
+   * @param[in] factoryCache The VisualFactoryCache object
+   */
+  TextVisual( VisualFactoryCache& factoryCache );
+
+  /**
+   * @brief A reference counted object may only be deleted by calling Unreference().
+   */
+  virtual ~TextVisual();
+
+  // from Visual::Base
+
   /**
-   * @copydoc Visual::Base::DoInitialize()
+   * @copydoc Visual::Base::DoSetProperties()
    */
-  virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
+  virtual void DoSetProperties( const Property::Map& propertyMap );
 
   /**
    * @copydoc Visual::Base::DoSetOnStage()
@@ -153,7 +169,7 @@ private:
 
 private:
   Text::ControllerPtr          mController;               ///< The text's controller.
-  Actor                        mSelf;
+  WeakHandle<Actor>            mSelf;
 
   Text::RendererPtr            mRenderer;
   Text::TextScrollerPtr        mTextScroller;