Fix crash when pressing up on an empty PopupMenu

This commit is contained in:
Michael Alexsander 2022-08-27 18:26:31 -03:00
parent 5beec641b6
commit f0d380c9fd

View file

@ -223,6 +223,7 @@ void PopupMenu::_scroll(float p_factor, const Point2 &p_over) {
void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) { void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) {
ERR_FAIL_COND(p_event.is_null()); ERR_FAIL_COND(p_event.is_null());
if (!items.empty()) {
if (p_event->is_action("ui_down") && p_event->is_pressed()) { if (p_event->is_action("ui_down") && p_event->is_pressed()) {
int search_from = mouse_over + 1; int search_from = mouse_over + 1;
if (search_from >= items.size()) { if (search_from >= items.size()) {
@ -312,6 +313,7 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) {
accept_event(); accept_event();
} }
} }
}
Ref<InputEventMouseButton> b = p_event; Ref<InputEventMouseButton> b = p_event;