From 42b8d04e46369432776a9a8883d45a925ac8645d Mon Sep 17 00:00:00 2001 From: David Capello Date: Fri, 2 Dec 2016 18:41:09 -0300 Subject: [PATCH] Fix crash clicking on a non-ListItem widget inside a multiselect ListBox --- src/ui/listbox.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/ui/listbox.cpp b/src/ui/listbox.cpp index 97a3c6a33..f49220e04 100644 --- a/src/ui/listbox.cpp +++ b/src/ui/listbox.cpp @@ -229,7 +229,7 @@ bool ListBox::onProcessMessage(Message* msg) } if (pick_item) { - Widget* picked; + Widget* picked = nullptr; if (view) { picked = view->viewport()->pick(mousePos); @@ -239,11 +239,8 @@ bool ListBox::onProcessMessage(Message* msg) } // If the picked widget is a child of the list, select it - if (picked && hasChild(picked)) { - if (ListItem* pickedItem = dynamic_cast(picked)) { - selectChild(pickedItem, msg); - } - } + if (picked && hasChild(picked)) + selectChild(picked, msg); } return true; @@ -365,7 +362,7 @@ void ListBox::onSizeHint(SizeHintEvent& ev) int w = 0, h = 0; UI_FOREACH_WIDGET_WITH_END(children(), it, end) { - Size reqSize = static_cast(*it)->sizeHint(); + Size reqSize = (*it)->sizeHint(); w = MAX(w, reqSize.w); h += reqSize.h + (it+1 != end ? this->childSpacing(): 0);