From ccb334a907d3f8388d5e326cba08779c085bbc59 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Tue, 22 Sep 2015 21:05:50 +0800 Subject: [PATCH] fix an crash that caused by accessing an non-existing tabbar --- source/gui/place_parts.hpp | 11 +++++------ source/gui/widgets/tabbar.cpp | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/source/gui/place_parts.hpp b/source/gui/place_parts.hpp index accb35c9..f82c043e 100644 --- a/source/gui/place_parts.hpp +++ b/source/gui/place_parts.hpp @@ -206,16 +206,15 @@ namespace nana caption_.create(*this, true); caption_.on_close([this] { - bool destroy_dockarea = false; - try + bool destroy_dockarea = true; + + if (tabbar_) { tabbar_->erase(tabbar_->selected()); + destroy_dockarea = (0 == tabbar_->length()); } - catch (std::out_of_range&) - { - destroy_dockarea = true; - } + if (destroy_dockarea) notifier_->request_close(); diff --git a/source/gui/widgets/tabbar.cpp b/source/gui/widgets/tabbar.cpp index 959d5ff7..bbaabeeb 100644 --- a/source/gui/widgets/tabbar.cpp +++ b/source/gui/widgets/tabbar.cpp @@ -1684,7 +1684,7 @@ namespace nana if (close_attached && attached_wd) API::close_window(attached_wd); - if (selection_changed) + if (selection_changed && (active_pos != npos)) { event_arg arg; events().selected.emit(arg);