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

EMSUSD-852 allow saving locked layers #3504

Merged
merged 2 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions lib/usd/ui/layerEditor/layerTreeItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,21 @@ bool LayerTreeItem::isIncoming() const { return _isIncomingLayer; }

bool LayerTreeItem::needsSaving() const
{
if (_layer) {
if (!isSessionLayer() && !isReadOnly()
Copy link
Collaborator Author

@pierrebai-adsk pierrebai-adsk Dec 8, 2023

Choose a reason for hiding this comment

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

The removal of the call to isReadOnly() is the only real change, all the other is just avoiding the complex nesting of conditionals and multi-line conditions, allowing to document what each condition does.

Copy link
Collaborator

@samuelliu-adsk samuelliu-adsk Dec 11, 2023

Choose a reason for hiding this comment

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

So if I understand it correctly, the needsSaving() function will return true even if permissionToSave is false, and that flag will be checked later when actually writing the layer

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

NO, isReadOnly checks permission to edit, not save. We currently do not have check for permission to save, but then again, USD itself will refuse to save, so we don't need to check it to prevent it. When we do the future work to have a UI for permission to save, we might had new verifications.

&& (_isSharedStage || parentLayerItem() != nullptr)) {
return isDirty() || isAnonymous();
}
}
return false;
// If for any reason we don't hold a layer, then we cannot save it.
if (!_layer)
return false;

// Session layers are managed by Maya, not the Layer Editor,
// so their dirty state does not count.
if (isSessionLayer())
return false;

// The stage is not shared, layers are assumed to be managed
// somewhere else and do not get saved here.
if (!_isSharedStage)
return false;

return isDirty() || isAnonymous();
}

// delegate Action API for command buttons
Expand Down
2 changes: 1 addition & 1 deletion lib/usd/ui/layerEditor/layerTreeView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void LayerTreeView::onItemDoubleClicked(const QModelIndex& index)
{
if (index.isValid()) {
auto layerTreeItem = layerItemFromIndex(index);
if (layerTreeItem->isAnonymous()) {
if (layerTreeItem->needsSaving()) {
layerTreeItem->saveEdits();
}
}
Expand Down
Loading