fix crash occurs when listbox is selecting item after pressing shift(#312)
This commit is contained in:
parent
335305c97c
commit
9370f13a1b
@ -1522,9 +1522,37 @@ namespace nana
|
||||
return n;
|
||||
}
|
||||
|
||||
template<typename Pred>
|
||||
std::vector<std::pair<index_pair, bool>> select_display_range_if(const index_pair& fr_abs, index_pair to_dpl, bool deselect_others, Pred pred)
|
||||
/// Finds a good item or category if an item specified by pos is invaild
|
||||
index_pair find_next_good(index_pair pos, bool ignore_category) const noexcept
|
||||
{
|
||||
//Return the pos if it is good
|
||||
if (this->good(pos))
|
||||
return pos;
|
||||
|
||||
while(pos.cat < this->categories_.size())
|
||||
{
|
||||
if ((pos.npos == pos.item) && !ignore_category)
|
||||
return pos;
|
||||
|
||||
auto cat_item_size = this->get(pos.cat)->items.size();
|
||||
|
||||
if (pos.item < cat_item_size)
|
||||
return pos;
|
||||
|
||||
if ((pos.npos == pos.item) && (cat_item_size > 0) && ignore_category)
|
||||
return index_pair{ pos.cat, 0 };
|
||||
|
||||
++pos.cat;
|
||||
pos.item = pos.npos;
|
||||
}
|
||||
return index_pair{};
|
||||
}
|
||||
|
||||
template<typename Pred>
|
||||
std::vector<std::pair<index_pair, bool>> select_display_range_if(index_pair fr_abs, index_pair to_dpl, bool deselect_others, Pred pred)
|
||||
{
|
||||
fr_abs = find_next_good(fr_abs, true);
|
||||
|
||||
if (to_dpl.empty())
|
||||
{
|
||||
if (fr_abs.empty())
|
||||
@ -1533,6 +1561,7 @@ namespace nana
|
||||
to_dpl = this->last();
|
||||
}
|
||||
|
||||
|
||||
auto fr_dpl = (fr_abs.is_category() ? fr_abs : this->index_cast(fr_abs, false)); //Converts an absolute position to display position
|
||||
if (fr_dpl > to_dpl)
|
||||
std::swap(fr_dpl, to_dpl);
|
||||
|
Loading…
x
Reference in New Issue
Block a user