From eadc5ae6b8eaadce00579af0e4598299e3521716 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Fri, 26 Jan 2018 14:52:51 +0100 Subject: [PATCH] fix(class_header.mustache): avoid memory leak on listener destructor => add virtual destructor on listener --- wrappers/cpp/class_header.mustache | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/wrappers/cpp/class_header.mustache b/wrappers/cpp/class_header.mustache index 71bd810fb..98da45224 100644 --- a/wrappers/cpp/class_header.mustache +++ b/wrappers/cpp/class_header.mustache @@ -71,7 +71,7 @@ namespace linphone { {{#friendClasses}} friend class {{name}}; {{/friendClasses}} - + public: {{#isNotListener}} {{#isrefcountable}} @@ -86,7 +86,7 @@ namespace linphone { {{/isnotrefcountable}} LINPHONECXX_PUBLIC {{{privCClassName}}} *cPtr() {return ({{{privCClassName}}} *)mPrivPtr;} {{/isNotListener}} - + {{#ismonolistenable}} LINPHONECXX_PUBLIC void setListener(const std::shared_ptr<{{{listenerClassName}}}> &listener); {{/ismonolistenable}} @@ -96,7 +96,11 @@ namespace linphone { LINPHONECXX_PUBLIC void addListener(const std::shared_ptr<{{{listenerClassName}}}> &listener); LINPHONECXX_PUBLIC void removeListener(const std::shared_ptr<{{{listenerClassName}}}> &listener); {{/ismultilistenable}} - + + {{#isListener}} + LINPHONECXX_PUBLIC virtual ~{{{className}}}() = default; + {{/isListener}} + public: {{#isfactory}} LINPHONECXX_PUBLIC std::shared_ptr createCore(const std::shared_ptr &listener, const std::string & configPath, const std::string & factoryConfigPath) const; @@ -105,8 +109,8 @@ namespace linphone { {{#isVcard}} LINPHONECXX_PUBLIC std::shared_ptr &getVcard(); {{/isVcard}} - - + + {{#methods}} /** {{#briefDoc}} @@ -122,7 +126,7 @@ namespace linphone { {{/detailedDoc}} */ LINPHONECXX_PUBLIC {{#deprecated}}LINPHONECXX_DEPRECATED {{/deprecated}}{{#isListener}}virtual {{/isListener}}{{{declPrototype}}}{{{suffix}}}; - + {{/methods}} {{#staticMethods}}; /** @@ -139,20 +143,20 @@ namespace linphone { {{/detailedDoc}} */ LINPHONECXX_PUBLIC {{#deprecated}}LINPHONECXX_DEPRECATED {{/deprecated}}static {{{declPrototype}}}; - + {{/staticMethods}} {{#ismultilistenable}} private: static void *createCallbacks(void *userData); {{/ismultilistenable}} - - + + {{#ismultilistenable}} private: void *mCallbacks; {{/ismultilistenable}} - + {{#isnotrefcountable}} private: void *mPrivPtr;