From f26131fca5ce0fa53158a9e9b4f2d0a275cdc1e9 Mon Sep 17 00:00:00 2001 From: Marcel Admiraal Date: Tue, 8 Sep 2020 10:20:07 +0100 Subject: [PATCH] Check if old mouse column is still available. (cherry picked from commit 79802b31a99f2b7256ad6d22e664734ee3a11397) --- scene/gui/tree.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index db6a28c73fc..f9130e2f06b 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -2514,11 +2514,16 @@ void Tree::_gui_input(Ref p_event) { cache.hover_cell = col; if (it != old_it || col != old_col) { - // Only need to update if mouse enters/exits a button - bool was_over_button = old_it && old_it->cells[old_col].custom_button; - bool is_over_button = it && it->cells[col].custom_button; - if (was_over_button || is_over_button) { + if (old_it && old_col >= old_it->cells.size()) { + // Columns may have changed since last update(). update(); + } else { + // Only need to update if mouse enters/exits a button + bool was_over_button = old_it && old_it->cells[old_col].custom_button; + bool is_over_button = it && it->cells[col].custom_button; + if (was_over_button || is_over_button) { + update(); + } } } }