From 4aba8e8c7ff284f367ea286d957e41f89e3a4ccf Mon Sep 17 00:00:00 2001 From: Jinhao Date: Wed, 26 Apr 2017 05:26:39 +0800 Subject: [PATCH] fix memory leak for spinbox --- include/nana/gui/widgets/spinbox.hpp | 1 + include/nana/gui/widgets/widget.hpp | 8 ++++---- source/gui/widgets/spinbox.cpp | 5 +++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/include/nana/gui/widgets/spinbox.hpp b/include/nana/gui/widgets/spinbox.hpp index 567a219c..2ecabc78 100644 --- a/include/nana/gui/widgets/spinbox.hpp +++ b/include/nana/gui/widgets/spinbox.hpp @@ -56,6 +56,7 @@ namespace nana private: //Overrides drawer_trigger void attached(widget_reference, graph_reference) override; + void detached() override; void refresh(graph_reference) override; void focus(graph_reference, const arg_focus&) override; diff --git a/include/nana/gui/widgets/widget.hpp b/include/nana/gui/widgets/widget.hpp index 2aed3a8e..c355e97b 100644 --- a/include/nana/gui/widgets/widget.hpp +++ b/include/nana/gui/widgets/widget.hpp @@ -1,7 +1,7 @@ /** * The fundamental widget class implementation * Nana C++ Library(http://www.nanapro.org) - * Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com) + * Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com) * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at @@ -245,9 +245,9 @@ namespace nana void _m_notify_destroy() override final { - widget_base::_m_notify_destroy(); events_ = std::make_shared(); API::dev::set_events(handle_, events_); + widget_base::_m_notify_destroy(); } private: DrawerTrigger trigger_; @@ -310,9 +310,9 @@ namespace nana void _m_notify_destroy() override final { - widget_base::_m_notify_destroy(); events_ = std::make_shared(); API::dev::set_events(handle_, events_); + widget_base::_m_notify_destroy(); } private: std::shared_ptr events_; @@ -449,9 +449,9 @@ namespace nana void _m_notify_destroy() override final { - widget_base::_m_notify_destroy(); events_ = std::make_shared(); API::dev::set_events(handle_, events_); + widget_base::_m_notify_destroy(); } private: DrawerTrigger trigger_; diff --git a/source/gui/widgets/spinbox.cpp b/source/gui/widgets/spinbox.cpp index 50c3eddc..87cec724 100644 --- a/source/gui/widgets/spinbox.cpp +++ b/source/gui/widgets/spinbox.cpp @@ -531,6 +531,11 @@ namespace nana impl_->attach(wdg, graph); } + void drawer::detached() + { + impl_->detach(); + } + void drawer::refresh(graph_reference) { impl_->render();