Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAYA-104778: Handle two more illegal cases: #659

Merged
merged 2 commits into from
Jul 15, 2020

Conversation

HamedSabri-adsk
Copy link
Contributor

  • Spaces are replaced with "_"
  • Names are not allowed to start with digits.

- Spaces are replaced with "_"
- Names are not allowed to start with digits.
@HamedSabri-adsk HamedSabri-adsk added ufe-usd Related to UFE-USD plugin in Maya-Usd workflows Related to in-context workflows labels Jul 14, 2020
// all special characters are replaced with `_`
const std::string specialChars{"~!@#$%^&*()-=+,.?`':{}|<>[]/"};
const std::string specialChars{"~!@#$%^&*()-=+,.?`':{}|<>[]/' '"};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space also needs to be replaced with under score.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think you added the space AND the two single quotes, which you don't need because you're in a string. In fact, the single quote is already in your string, so now you have it 3 times...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ppt-adsk Duh!! Thanks. I could use std::isspace for sake of readability but that's something for later. All these string manipulation and logics could also go to somewhere like stringUtils.h later on.

See bb59f68

// names are not allowed to start to digit numbers
if(std::isdigit(_newName.at(0))){
_newName = prim.GetName();
}
Copy link
Contributor Author

@HamedSabri-adsk HamedSabri-adsk Jul 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Names are not allowed to start with digits and should be replaced with the old name. This is based on Natalia's request to match Maya's behavior.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, Maya's behavior is confusing / buggy. Here's what I get when I rename a sphere with a leading numeric:
select -r pSphere1 ;
rename "pSphere1" "1pSphere1";
// Warning: line 1: New name contains invalid characters. Illegal characters were converted to "_". //
// Result: pSphere1 //

Yes, you do get the old name back, but you also get a warning saying "illegal character" will be replaced with an underscore --- and then you don't get the underscore...

Copy link
Contributor Author

@HamedSabri-adsk HamedSabri-adsk Jul 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, Maya's behavior is confusing / buggy. Here's what I get when I rename a sphere with a leading numeric:
select -r pSphere1 ;
rename "pSphere1" "1pSphere1";
// Warning: line 1: New name contains invalid characters. Illegal characters were converted to "_". //
// Result: pSphere1 //

Yes, you do get the old name back, but you also get a warning saying "illegal character" will be replaced with an underscore --- and then you don't get the underscore...

@ppt-adsk Can't agree more. I have noticed this as well and it is very confusing.

I've already brought this up with design team and not really sure if we want to mimic exactly how Maya's handling all these cases.

My main goal for now is to prevent Maya crash when illegal characters are used in names.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O.K., fair enough, so for now, no crash, but no warning, and no underscore. Works for me.

// names are not allowed to start to digit numbers
if(std::isdigit(_newName.at(0))){
_newName = prim.GetName();
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, Maya's behavior is confusing / buggy. Here's what I get when I rename a sphere with a leading numeric:
select -r pSphere1 ;
rename "pSphere1" "1pSphere1";
// Warning: line 1: New name contains invalid characters. Illegal characters were converted to "_". //
// Result: pSphere1 //

Yes, you do get the old name back, but you also get a warning saying "illegal character" will be replaced with an underscore --- and then you don't get the underscore...

// all special characters are replaced with `_`
const std::string specialChars{"~!@#$%^&*()-=+,.?`':{}|<>[]/"};
const std::string specialChars{"~!@#$%^&*()-=+,.?`':{}|<>[]/' '"};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think you added the space AND the two single quotes, which you don't need because you're in a string. In fact, the single quote is already in your string, so now you have it 3 times...

// names are not allowed to start to digit numbers
if(std::isdigit(_newName.at(0))){
_newName = prim.GetName();
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O.K., fair enough, so for now, no crash, but no warning, and no underscore. Works for me.

@kxl-adsk kxl-adsk merged commit 0e8ea7c into dev Jul 15, 2020
@kxl-adsk kxl-adsk deleted the sabrih/MAYA-104778/handle_illegal_char branch July 15, 2020 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ufe-usd Related to UFE-USD plugin in Maya-Usd workflows Related to in-context workflows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants