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-109647 - Target becomes out of synch when an ancestor of a targe… #1156

Merged
merged 2 commits into from
Feb 10, 2021

Conversation

spinell-adsk
Copy link
Contributor

…t layer is being removed

Set the root layer as the edittarget when the current edit target is removed

…t layer is being removed

Set the root layer as the edittarget when the current edit target is removed
…t layer is being removed

Fix build on MacOS -- error: lambda capture 'this' is not used
Copy link
Contributor

@fowlertADSK fowlertADSK left a comment

Choose a reason for hiding this comment

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

Just wondering if instead of recursively trying to figure everything out we could just check if the edit target got lost after the operation? If we do correctly catch the situation then we’re just going to go with the root layer anyways right?

e.g. logic kind of like…
auto originalEditTarget = stage->GetEditTarget();
… do work …
auto currentEditTarget = stage->GetEditTarget();

if (nullptr != originalEditTarget && nullptr == currentEditTarget)
{
// The edit target was set to something but now it isn’t set to anything.
// Must have removed a parent layer?
stage->SetEditTarget(stage->GetRootLayer());
}

@fowlertADSK
Copy link
Contributor

Replying to my own comment... Took another look at this and I think I missed something when I first looked at it. Is it the case that you are not trying to figure out AFTER the fact that the edit target got removed, you are trying to figure out BEFORE you attempt to remove the layer so that the edit is stored in something that will still be valid after the operation.

I first read the diff as trying to clean up after the fact and I was going to suggest using something like stage->HasLocalLayer(currentTarget.GetLayer()) to figure out of the layer is still valid after the operation, but now that I look closer this is all happening before the removal.

@spinell-adsk
Copy link
Contributor Author

@fowlertADSK what you were proposing about querying stage->GetEditTarget() after removing the layer it's exactly what I first try. There is a few issue with this way.

When removing an anonymous layer, the command keep a reference to the layer for the undo operation. So USD never delete the layer and stage->GetEditTarget() return the same layer after the remove operation.

If the layer to remove is based on a file and the LayerEditor windows is open, USD will not delete the layer when calling RemoveSubLayerPath() because the UI still have a reference on the layer. The layer will be delete on th next UI refresh which happen after the command end and tage->GetEditTarget() return the same layer after the remove operation.

If the layer to remove is based on a file and the LayerEditor windows is not open, USD will delete the layer when calling RemoveSubLayerPath() and and tage->GetEditTarget() return a invalid layer.

@spinell-adsk spinell-adsk added the ready-for-merge Development process is finished, PR is ready for merge label Feb 10, 2021
@kxl-adsk kxl-adsk merged commit 0e41de0 into dev Feb 10, 2021
@kxl-adsk kxl-adsk deleted the spinell/MAYA-109647/remove_layer_edit_target branch February 10, 2021 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge Development process is finished, PR is ready for merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants