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 b2d0b004cbb1069c0eb588829892e7769f825eff..6b1401cca2712bf5863ba3e4376e2c01b710028d 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 b2e98e2f21440035f46e61f16c08cdb937e3b88f..15a339db8c62177f4a1feffee9af870e610d71fc 100644 (file)
@@ -19,6 +19,8 @@
  */
 
 // EXTERNAL INCLUDES
+#include <memory>
+
 #include <dali/public-api/object/property-map.h>
 
 // INTERNAL INCLUDES
@@ -39,6 +41,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