diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-08-31 17:36:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-31 17:36:29 +0200 |
commit | f4ec011c29b036d665fcb9c7a09d23f5beee3af3 (patch) | |
tree | 137886671259c1630969398e11bbe66b8e6cb2b4 | |
parent | 818af9618996b392d7494338ba31924c80ef0406 (diff) | |
parent | 96bdcfd44746e614a8ad6e5a45d2ed86a2dca1c5 (diff) |
Merge pull request #65142 from RedMser/fix-65122-freeze
Fix `EditorNode::disambiguate_filenames` freeze
-rw-r--r-- | editor/editor_node.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index b58917aae2..d84cb11312 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -253,11 +253,8 @@ void EditorNode::disambiguate_filenames(const Vector<String> p_full_paths, Vecto } // Normalize trailing slashes when normalizing directory names. - if (scene_name.rfind("/") == scene_name.length() - 1 && full_path.rfind("/") != full_path.length() - 1) { - full_path = full_path + "/"; - } else if (scene_name.rfind("/") != scene_name.length() - 1 && full_path.rfind("/") == full_path.length() - 1) { - scene_name = scene_name + "/"; - } + scene_name = scene_name.trim_suffix("/"); + full_path = full_path.trim_suffix("/"); int scene_name_size = scene_name.size(); int full_path_size = full_path.size(); @@ -301,17 +298,23 @@ void EditorNode::disambiguate_filenames(const Vector<String> p_full_paths, Vecto // and the scene name first to remove extensions so that this // comparison actually works. String path = p_full_paths[E->get()]; + + // Get rid of file extensions and res:// prefixes. + if (scene_name.rfind(".") >= 0) { + scene_name = scene_name.substr(0, scene_name.rfind(".")); + } if (path.begins_with("res://")) { path = path.substr(6); } if (path.rfind(".") >= 0) { path = path.substr(0, path.rfind(".")); } - if (scene_name.rfind(".") >= 0) { - scene_name = scene_name.substr(0, scene_name.rfind(".")); - } - // We can proceed iff the full path is longer than the scene name, + // Normalize trailing slashes when normalizing directory names. + scene_name = scene_name.trim_suffix("/"); + path = path.trim_suffix("/"); + + // We can proceed if the full path is longer than the scene name, // meaning that there is at least one more parent folder we can // tack onto the name. can_proceed = can_proceed || (path.size() - scene_name.size()) >= 1; |