From 80ceb2407f7f9a92a7cffa46f4e60d93be273440 Mon Sep 17 00:00:00 2001 From: Francisco Santos Date: Wed, 8 Nov 2017 21:49:57 +0000 Subject: [PATCH] [4.0] Fix memory leak in InputMethodOptions Change-Id: I60cf0fad5f3757a162856910b83bc455a79939e7 (cherry picked from commit 00bf7437881db649e758838b78a2cb7fdd6c6fd6) --- adaptors/devel-api/adaptor-framework/input-method-options.cpp | 8 +++++++- adaptors/devel-api/adaptor-framework/input-method-options.h | 9 ++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/adaptors/devel-api/adaptor-framework/input-method-options.cpp b/adaptors/devel-api/adaptor-framework/input-method-options.cpp index b2d0b00..6b1401c 100644 --- a/adaptors/devel-api/adaptor-framework/input-method-options.cpp +++ b/adaptors/devel-api/adaptor-framework/input-method-options.cpp @@ -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() diff --git a/adaptors/devel-api/adaptor-framework/input-method-options.h b/adaptors/devel-api/adaptor-framework/input-method-options.h index b2e98e2..15a339d 100644 --- a/adaptors/devel-api/adaptor-framework/input-method-options.h +++ b/adaptors/devel-api/adaptor-framework/input-method-options.h @@ -19,6 +19,8 @@ */ // EXTERNAL INCLUDES +#include + #include // 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 mImpl; }; } // namespace Dali -- 2.7.4