diff --git a/include/nana/gui/widgets/widget.hpp b/include/nana/gui/widgets/widget.hpp index 18163f61..0288388e 100644 --- a/include/nana/gui/widgets/widget.hpp +++ b/include/nana/gui/widgets/widget.hpp @@ -31,7 +31,7 @@ namespace nana : nana::noncopyable, nana::nonmovable { friend class detail::widget_notifier_interface; - class notifier; + class inner_widget_notifier; typedef void(*dummy_bool_type)(widget* (*)(const widget&)); public: virtual ~widget() = default; diff --git a/source/gui/detail/window_manager.cpp b/source/gui/detail/window_manager.cpp index 4ba1c3a2..e9581fd1 100644 --- a/source/gui/detail/window_manager.cpp +++ b/source/gui/detail/window_manager.cpp @@ -326,6 +326,9 @@ namespace detail std::lock_guard lock(mutex_); if (impl_->wd_register.available(wd) == false) return; + if (wd->flags.destroying) + return; + if(wd->other.category == category::root_tag::value) { auto &brock = bedrock::instance(); @@ -340,13 +343,15 @@ namespace detail if(wd->flags.modal || (wd->owner == nullptr) || wd->owner->flags.take_active) native_interface::activate_owner(wd->root); - //Close should detach the drawer and send destroy signal to widget object. - //Otherwise, when a widget object is been deleting in other thread by delete operator, the object will be destroyed - //before the window_manager destroyes the window, and then, window_manager detaches the - //non-existing drawer_trigger which is destroyed by destruction of widget. Crash! - wd->drawer.detached(); - - wd->widget_notifier->destroy(); + if (!wd->flags.destroying) + { + //Close should detach the drawer and send destroy signal to widget object. + //Otherwise, when a widget object is been deleting in other thread by delete operator, the object will be destroyed + //before the window_manager destroyes the window, and then, window_manager detaches the + //non-existing drawer_trigger which is destroyed by destruction of widget. Crash! + wd->drawer.detached(); + wd->widget_notifier->destroy(); + } native_interface::close_window(wd->root); } diff --git a/source/gui/widgets/tabbar.cpp b/source/gui/widgets/tabbar.cpp index 6532bf6e..8b82c6d0 100644 --- a/source/gui/widgets/tabbar.cpp +++ b/source/gui/widgets/tabbar.cpp @@ -1440,7 +1440,6 @@ namespace nana private: void _m_calc_metrics(graph_reference graph, std::forward_list& items) { - const auto height_px = graph.height(); std::vector pxs; unsigned pixels = 0; diff --git a/source/gui/widgets/widget.cpp b/source/gui/widgets/widget.cpp index af853b38..39a2ac57 100644 --- a/source/gui/widgets/widget.cpp +++ b/source/gui/widgets/widget.cpp @@ -22,10 +22,10 @@ namespace nana //class widget //@brief:The definition of class widget - class widget::notifier: public detail::widget_notifier_interface + class widget::inner_widget_notifier : public detail::widget_notifier_interface { public: - notifier(widget& wdg) + inner_widget_notifier(widget& wdg) : wdg_(wdg) {} @@ -246,7 +246,7 @@ namespace nana std::unique_ptr<::nana::detail::widget_notifier_interface> widget::_m_wdg_notifier() { - return std::unique_ptr<::nana::detail::widget_notifier_interface>(new notifier(*this)); + return std::unique_ptr<::nana::detail::widget_notifier_interface>(new inner_widget_notifier(*this)); } void widget::_m_complete_creation() @@ -348,7 +348,7 @@ namespace nana { std::unique_ptr widget_notifier_interface::get_notifier(widget* wdg) { - return std::unique_ptr(new widget::notifier(*wdg)); + return std::unique_ptr(new widget::inner_widget_notifier(*wdg)); } } }//end namespace nana