mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-22 03:46:50 +01:00
Fix SceneTree dock filter crash
The filter was crashing for two reasons: 1) Deleting a child invalidated the iteration of children 2) Child was accessed after deletion
This commit is contained in:
parent
11cdb79005
commit
a607ec6545
@ -637,9 +637,16 @@ bool SceneTreeEditor::_update_filter(TreeItem *p_parent, bool p_scroll_to_select
|
||||
}
|
||||
|
||||
bool keep_for_children = false;
|
||||
|
||||
// Get the list of children ahead of time, as the list may be invalidated by deleting one of them.
|
||||
LocalVector<TreeItem *> children;
|
||||
for (TreeItem *child = p_parent->get_children(); child; child = child->get_next()) {
|
||||
children.push_back(child);
|
||||
}
|
||||
|
||||
for (uint32_t n = 0; n < children.size(); n++) {
|
||||
// Always keep if at least one of the children are kept.
|
||||
keep_for_children = _update_filter(child, p_scroll_to_selected) || keep_for_children;
|
||||
keep_for_children = _update_filter(children[n], p_scroll_to_selected) || keep_for_children;
|
||||
}
|
||||
|
||||
// Now find other reasons to keep this Node, too.
|
||||
|
Loading…
Reference in New Issue
Block a user