Merge pull request #44887 from gongpha/crash!-on-expand-or-collapse-folder-in-filesystem-tree

Fix crash on FileSystemDock's tree when trying to collapse or expand folder
This commit is contained in:
Rémi Verschelde 2021-01-26 15:32:15 +01:00 committed by GitHub
commit 9c50d0ee0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -76,6 +76,9 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory
subdirectory_item->set_metadata(0, lpath);
if (!p_select_in_favorites && (path == lpath || ((display_mode == DISPLAY_MODE_SPLIT) && path.get_base_dir() == lpath))) {
subdirectory_item->select(0);
// Keep select an item when re-created a tree
// To prevent crashing when nothing is selected.
subdirectory_item->set_as_cursor(0);
}
if (p_unfold_path && path.begins_with(lpath) && path != lpath) {