Merge "Fix memory leak in InputMethodOptions" into devel/master
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Fri, 10 Nov 2017 17:08:14 +0000 (17:08 +0000)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Fri, 10 Nov 2017 17:08:14 +0000 (17:08 +0000)
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