Fix failing ASSERT(i >= 0 && i < int(m_states.size())) in ListBox::selectChild()

We receive kMouseMoveMessage as the first message of a multiselect
message in a ListBox when the kMouseDownMessage message is received by
a separator first e.g. if we click a separator from the Recover Files
tab and start dragging the mouse this assert was failing.
This commit is contained in:
David Capello 2023-04-17 22:32:22 -03:00
parent 79745756ef
commit f0e80f1b5a

View File

@ -81,6 +81,7 @@ void ListBox::selectChild(Widget* item, Message* msg)
// Save current state of all children when we start selecting
if (msg == nullptr ||
msg->type() == kMouseDownMessage ||
(msg->type() == kMouseMoveMessage && m_firstSelectedIndex < 0) ||
msg->type() == kKeyDownMessage) {
m_firstSelectedIndex = itemIndex;
m_states.resize(children().size());
@ -256,8 +257,11 @@ bool ListBox::onProcessMessage(Message* msg)
return true;
case kMouseUpMessage:
if (hasCapture())
if (hasCapture()) {
releaseMouse();
m_firstSelectedIndex = -1;
m_lastSelectedIndex = -1;
}
return true;
case kMouseWheelMessage: {