Skip to content

Commit

Permalink
Merge pull request godotengine#79050 from capnm/fix_teststr_what
Browse files Browse the repository at this point in the history
Fix import hints that are followed by dot.number
  • Loading branch information
YuriSizov authored Jul 5, 2023
2 parents e5cca53 + 470083c commit c16afc1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion doc/classes/String.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@
<method name="validate_node_name" qualifiers="const">
<return type="String" />
<description>
Returns a copy of the string with all characters that are not allowed in [member Node.name] removed ([code].[/code] [code]:[/code] [code]@[/code] [code]/[/code] [code]"[/code] [code]%[/code]).
Returns a copy of the string with all characters that are not allowed in [member Node.name] ([code].[/code] [code]:[/code] [code]@[/code] [code]/[/code] [code]"[/code] [code]%[/code]) replaced with underscores.
</description>
</method>
<method name="xml_escape" qualifiers="const">
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/StringName.xml
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@
<method name="validate_node_name" qualifiers="const">
<return type="String" />
<description>
Returns a copy of the string with all characters that are not allowed in [member Node.name] removed ([code].[/code] [code]:[/code] [code]@[/code] [code]/[/code] [code]"[/code] [code]%[/code]).
Returns a copy of the string with all characters that are not allowed in [member Node.name] ([code].[/code] [code]:[/code] [code]@[/code] [code]/[/code] [code]"[/code] [code]%[/code]) replaced with underscores.
</description>
</method>
<method name="xml_escape" qualifiers="const">
Expand Down
10 changes: 6 additions & 4 deletions editor/import/resource_importer_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,9 @@ String ResourceImporterScene::get_preset_name(int p_idx) const {
static bool _teststr(const String &p_what, const String &p_str) {
String what = p_what;

//remove trailing spaces and numbers, some apps like blender add ".number" to duplicates so also compensate for this
while (what.length() && (is_digit(what[what.length() - 1]) || what[what.length() - 1] <= 32 || what[what.length() - 1] == '.')) {
// Remove trailing spaces and numbers, some apps like blender add ".number" to duplicates
// (dot is replaced with _ as invalid character) so also compensate for this.
while (what.length() && (is_digit(what[what.length() - 1]) || what[what.length() - 1] <= 32 || what[what.length() - 1] == '_')) {
what = what.substr(0, what.length() - 1);
}

Expand All @@ -333,8 +334,9 @@ static bool _teststr(const String &p_what, const String &p_str) {
static String _fixstr(const String &p_what, const String &p_str) {
String what = p_what;

//remove trailing spaces and numbers, some apps like blender add ".number" to duplicates so also compensate for this
while (what.length() && (is_digit(what[what.length() - 1]) || what[what.length() - 1] <= 32 || what[what.length() - 1] == '.')) {
// Remove trailing spaces and numbers, some apps like blender add ".number" to duplicates
// (dot is replaced with _ as invalid character) so also compensate for this.
while (what.length() && (is_digit(what[what.length() - 1]) || what[what.length() - 1] <= 32 || what[what.length() - 1] == '_')) {
what = what.substr(0, what.length() - 1);
}

Expand Down

0 comments on commit c16afc1

Please sign in to comment.