diff options
Diffstat (limited to 'scene/gui/tree.cpp')
-rw-r--r-- | scene/gui/tree.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 47761d724e..eeb7f9430d 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -3419,6 +3419,8 @@ void Tree::scroll_to_item(TreeItem *p_item) { TreeItem *Tree::_search_item_text(TreeItem *p_at, const String &p_find, int *r_col, bool p_selectable, bool p_backwards) { TreeItem *from = p_at; + TreeItem *loop = nullptr; // Safe-guard against infinite loop. + while (p_at) { for (int i = 0; i < columns.size(); i++) { if (p_at->get_text(i).findn(p_find) == 0 && (!p_selectable || p_at->is_selectable(i))) { @@ -3438,6 +3440,12 @@ TreeItem *Tree::_search_item_text(TreeItem *p_at, const String &p_find, int *r_c if ((p_at) == from) { break; } + + if (!loop) { + loop = p_at; + } else if (loop == p_at) { + break; + } } return nullptr; |