Fix memory leak in InputMethodOptions 13/159413/2
authorFrancisco Santos <f1.santos@samsung.com>
Wed, 8 Nov 2017 21:49:57 +0000 (21:49 +0000)
committerFrancisco Santos <f1.santos@samsung.com>
Thu, 9 Nov 2017 11:10:47 +0000 (11:10 +0000)
Change-Id: I60cf0fad5f3757a162856910b83bc455a79939e7

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