From 5982f8c7bfcb29748aaf1eb509d289dbde85ebf8 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Tue, 16 Jun 2015 00:12:09 +0800 Subject: [PATCH] fix a crash error when click on an empty category of listbox --- source/gui/widgets/listbox.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index 9c8eccf7..8b2af38f 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -1591,7 +1591,7 @@ namespace nana } /// set all items in cat to selection sel, emiting events, actualizing last_selected_abs, but not check for single_selection_ - bool categ_selected(size_type cat, bool sel); + void categ_selected(size_type cat, bool sel); void reverse_categ_selected(size_type categ) { @@ -2481,21 +2481,16 @@ namespace nana return list_str ; } - bool es_lister::categ_selected(size_type cat, bool sel) + void es_lister::categ_selected(size_type cat, bool sel) { - bool changed = false; // we need this?? - cat_proxy cpx{ess_,cat}; for (item_proxy &it : cpx ) { if (it.selected() != sel) - changed = true; - it.select(sel); + it.select(sel); } last_selected_abs = last_selected_dpl = index_pair {cat, npos}; - - return changed; // we need this?? } class drawer_header_impl @@ -3823,6 +3818,11 @@ namespace nana //Behavior of a container item_proxy cat_proxy::begin() const { + auto i = ess_->lister.cat_container().begin(); + std::advance(i, pos_); + if (i->items.empty()) + return end(); + return item_proxy(ess_, index_pair(pos_, 0)); }