[4.0] Fix memory leak in InputMethodOptions 47/160547/1
authorFrancisco Santos <f1.santos@samsung.com>
Wed, 8 Nov 2017 21:49:57 +0000 (21:49 +0000)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Thu, 16 Nov 2017 16:30:47 +0000 (16:30 +0000)
Change-Id: I60cf0fad5f3757a162856910b83bc455a79939e7
(cherry picked from commit 00bf7437881db649e758838b78a2cb7fdd6c6fd6)

adaptors/devel-api/adaptor-framework/input-method-options.cpp
adaptors/devel-api/adaptor-framework/input-method-options.h

index b2d0b00..6b1401c 100644 (file)
@@ -47,7 +47,13 @@ struct InputMethodOptions::Impl
 
 InputMethodOptions::InputMethodOptions()
 {
-  mImpl = new Impl( );
+  mImpl.reset(new Impl());
+}
+
+InputMethodOptions::~InputMethodOptions()
+{
+  // destructor cannot be inlined and must be in a unit
+  // for unique_ptr to work with forward declaration
 }
 
 bool InputMethodOptions::IsPassword()
index b2e98e2..15a339d 100644 (file)
@@ -19,6 +19,8 @@
  */
 
 // EXTERNAL INCLUDES
+#include <memory>
+
 #include <dali/public-api/object/property-map.h>
 
 // INTERNAL INCLUDES
@@ -40,6 +42,11 @@ public:
   InputMethodOptions();   /// Default InputMethodOptions options
 
   /**
+   * Destructor
+   */
+  ~InputMethodOptions();
+
+  /**
    * @brief Returns whether panel layout type is password or not
    * @return true if panel layout type is password, false otherwise.
    */
@@ -70,7 +77,7 @@ public: // Intended for internal use
 private:
 
   struct Impl;
-  Impl* mImpl;
+  std::unique_ptr<Impl> mImpl;
 };
 
 } // namespace Dali