-
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-1149 prevent unlocking system-locked layer when unlocking parents #3706
Conversation
pierrebai-adsk
commented
Apr 9, 2024
- When unlocking recursively, do not unlock sub-layers that are system-locked.
- Correctly check that the request was for system lock when undoing a lock command.
- Add more lock tests to cover more cases, like having sub-layers and system-locked layers.
- When unlocking recursively, do not unlock sub-layers that are system-locked. - Correctly check that the *request* was for system lock when undoing a lock command. - Add more lock tests to cover more cases, like having sub-layers and system-locked layers.
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.
The design for the locklayer command is to allow locking / systemlocking / unlocking any layer and its sublayers through script, but not through UI.
I believe this will prevent the scenario of going through the script.
Well, if we all recursive unlocking of system-locked layers in the command, then the recursive option will not be useful because we will need to do the recursion in the UI code and skip the system-locked layer. The UI will not be able to use the recursive flag. |
We may either have to add a new parameter to mark the command to be run as a super user or a way to pass the information through UI to know it's being run through there. Any other suggestions are also welcome! |
No, that starts to be byzantine. The Maya command hook will do the layer recursion. Maaaybe there could be a flag to skip system-locked layers? That seems reasonable. |
Either that or a generic way to indicate that overrides are allowed, but that creates the concept of user roles. |
…system-locked layers - Add a flag to control the lock command affecting sub-layers that are system-locked. - Use teh flag from the UI, in the Maya command hook. - Update the unit test.
Added -skipSystemLocked flag. Seems explicit enough to make its behavior clear. |
@@ -868,7 +883,7 @@ class LockLayer : public BaseCmd | |||
// Execute lock commands | |||
for (size_t layerIndex = 0; layerIndex < _layers.size(); layerIndex++) { | |||
// Note: the undo of system-locked is unlocked by design. | |||
if (_previousStates[layerIndex] == MayaUsd::LayerLockType::LayerLock_SystemLocked) { | |||
if (_lockType == MayaUsd::LayerLockType::LayerLock_SystemLocked) { |
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.
I believe this should also be conditioned?
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.
I don't understand what you mean
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.
The previous state will always have the correct value when undoing, so there is no need to protect, at worst it will set the same state it already was.
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.
As long as any consecutive number of system-locks results in Unlock, then it's all good.
@@ -208,8 +208,13 @@ void MayaCommandHook::lockLayer( | |||
MayaUsd::LayerLockType lockState, | |||
bool includeSubLayers) | |||
{ | |||
// Per design, we refuse to change the lock state of system-locked | |||
// layers through the UI. | |||
if (MayaUsd::isLayerSystemLocked(usdLayer)) |
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.
This also needs to be conditioned whether we skip system locked files or not.
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.
Again, I don't understand what you mean. We never want to affect system-locked layer from thr UI.
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.
Is it guaranteed that the mayaCommandHook is only called from the UI?
If so, then it's all good.
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.
What I would suggest though, is to add the skipSystemLocked
. Because unlike Muting, sub-layers of a system-locked layer can be unlocked.
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.
Ah, so we should et it do its work if include sub-layers is true? OK.
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.
Actually the code behind the lock layer and sublayer menu is
maya-usd/plugin/adsk/scripts/mayaUsdMenu.mel
Lines 945 to 953 in 7466596
if (!$isSessionLayer && $hasSublayers) { | |
if ($isLocked) | |
$label = getMayaUsdString("kMenuUnlockLayerAndSublayers"); | |
else | |
$label = getMayaUsdString("kMenuLockLayerAndSublayers"); | |
$cmd = makeCommand($panelName, "lockLayerAndSubLayers"); | |
$enabled = !$isSystemLocked; | |
menuItem -label $label -enable $enabled -c $cmd; | |
} |
which seems to be enabled only if the right-clicked layer isn't system locked.
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.
MayaCommandHook::lockLayer should allow unlocking sub-layers of a system-locked layer since the system-lock is not inheritance-based such as Muting layers.
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.
Actually, if the menu item is disabled, then there's no need to apply to sub-layers.
The sub-layers can be unlocked through the selection of those layers.
All good.