From 49dfaca1efada80df432ff5bd8ed90a4959c9909 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Wed, 13 Jul 2016 22:57:13 +0800 Subject: [PATCH] fix a crash when the listbox inserts an item. --- source/gui/widgets/listbox.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index f9ddfff5..332f9fce 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -961,7 +961,7 @@ namespace nana } /// Insert before item in absolute "pos" a new item with "text" in column 0, and place it in last display position of this cat - void insert(const index_pair& pos, std::string&& text) + void insert(const index_pair& pos, std::string&& text, std::size_t columns) { auto & catobj = *get(pos.cat); @@ -990,8 +990,8 @@ namespace nana container->emplace_back(); } - std::vector cells; - cells.emplace_back(std::move(text)); + std::vector cells{ columns }; + cells[0] = std::move(text); container->assign(item_index, cells); } else @@ -1000,9 +1000,9 @@ namespace nana catobj.items.emplace(catobj.items.begin() + pos.item, std::move(text)); else catobj.items.emplace_back(std::move(text)); - } - catobj.items.back().cells->emplace_back(std::move(text)); + catobj.items.back().cells->emplace_back(std::move(text)); + } } /// convert from display order to absolute (find the real item in that display pos) but without check from current active sorting, in fact using just the last sorting !!! @@ -5246,7 +5246,7 @@ namespace nana { internal_scope_guard lock; auto & ess = _m_ess(); - ess.lister.insert(pos, std::move(text)); + ess.lister.insert(pos, std::move(text), ess.header.cont().size()); if (!empty()) {