-
Notifications
You must be signed in to change notification settings - Fork 203
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
EMSUSD-1017 Fix reverting multiple files #3625
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,21 +39,6 @@ namespace { | |
|
||
std::string quote(const std::string& string) { return STR(" \"") + string + STR("\""); } | ||
|
||
MString executeMel(const std::string& commandString) | ||
{ | ||
// executes maya command with display and undo set to true so that it logs | ||
MStringArray result; | ||
MGlobal::executeCommand( | ||
MString(commandString.c_str()), | ||
result, | ||
/*display*/ true, | ||
/*undo*/ true); | ||
if (result.length() > 0) | ||
return result[0]; | ||
else | ||
return ""; | ||
} | ||
|
||
// maya doesn't support spaces in undo chunk names... | ||
MString cleanChunkName(QString name) { return quote(name.replace(" ", "_").toStdString()).c_str(); } | ||
|
||
|
@@ -195,8 +180,11 @@ UsdLayer MayaCommandHook::addAnonymousSubLayer(UsdLayer usdLayer, std::string ne | |
cmd = "mayaUsdLayerEditor -edit -addAnonymous "; | ||
cmd += quote(newName); | ||
cmd += quote(usdLayer->GetIdentifier()); | ||
std::string result = executeMel(cmd).asChar(); | ||
return PXR_NS::SdfLayer::FindOrOpen(result); | ||
std::string result = executeMel(cmd); | ||
if (result.size() > 0) | ||
return PXR_NS::SdfLayer::FindOrOpen(result); | ||
else | ||
return {}; | ||
} | ||
|
||
// mute or unmute the given layer | ||
|
@@ -207,7 +195,7 @@ void MayaCommandHook::muteSubLayer(UsdLayer usdLayer, bool muteIt) | |
cmd += muteIt ? "1" : "0"; | ||
cmd += quote(proxyShapePath()); | ||
cmd += quote(usdLayer->GetIdentifier()); | ||
executeMel(cmd).asChar(); | ||
executeMel(cmd); | ||
} | ||
|
||
// lock, system-lock or unlock the given layer | ||
|
@@ -236,7 +224,7 @@ void MayaCommandHook::lockSubLayer(UsdLayer usdLayer, MayaUsd::LayerLockType loc | |
|
||
cmd += quote(proxyShapePath()); | ||
cmd += quote(usdLayer->GetIdentifier()); | ||
executeMel(cmd).asChar(); | ||
executeMel(cmd); | ||
} | ||
|
||
// Help menu callback | ||
|
@@ -295,4 +283,50 @@ bool MayaCommandHook::isProxyShapeSharedStage(const std::string& proxyShapePath) | |
return getBooleanAttributeOnProxyShape(proxyShapePath, "shareStage"); | ||
} | ||
|
||
std::string MayaCommandHook::executeMel(const std::string& commandString) | ||
{ | ||
if (areCommandsDelayed()) { | ||
_delayedCommands.push_back({ commandString, false }); | ||
} else { | ||
// executes maya command with display and undo set to true so that it logs | ||
MStringArray result; | ||
MGlobal::executeCommand( | ||
MString(commandString.c_str()), | ||
result, | ||
/*display*/ true, | ||
/*undo*/ true); | ||
if (result.length() > 0) | ||
return result[0].asChar(); | ||
} | ||
return ""; | ||
} | ||
|
||
void MayaCommandHook::executePython(const std::string& commandString) | ||
{ | ||
if (areCommandsDelayed()) { | ||
_delayedCommands.push_back({ commandString, true }); | ||
} else { | ||
MGlobal::executePythonCommand(commandString.c_str()); | ||
} | ||
} | ||
|
||
void MayaCommandHook::executeDelayedCommands() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would you mind adding a comment that this function should not be called directly? |
||
{ | ||
if (areCommandsDelayed()) | ||
return; | ||
|
||
// In case the execution of commands add new commands, | ||
// make a copy and clear the delayed commands. | ||
std::vector<DelayedCommand> cmds = _delayedCommands; | ||
_delayedCommands.clear(); | ||
|
||
for (const auto& cmd : cmds) { | ||
if (cmd.isPython) { | ||
executePython(cmd.command); | ||
} else { | ||
executeMel(cmd.command); | ||
} | ||
} | ||
} | ||
|
||
} // namespace UsdLayerEditor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we always want to have display on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was like that in the existing code that I moved here from the top of the file.