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-108549: Fix undo crash when switching between target layers in a stage #965

Merged
Changes from 1 commit
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
8 changes: 7 additions & 1 deletion lib/mayaUsd/undo/UsdUndoManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ UsdUndoManager& UsdUndoManager::instance()

void UsdUndoManager::trackLayerStates(const SdfLayerHandle& layer)
{
layer->SetStateDelegate(UsdUndoStateDelegate::New());
// Check if the layer has already been given a UsdUndoStateDelegate
// if the cast fails that means we need to set a new one.
auto usdUndoStateDelegatePtr
= TfDynamic_cast<UsdUndoStateDelegatePtr>(layer->GetStateDelegate());
if (!usdUndoStateDelegatePtr) {
layer->SetStateDelegate(UsdUndoStateDelegate::New());
}
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 Thanks for great feedback. Using a dynamic_cast to determine if a layer is already registered with our UsdUndoStateDelegate. If the cast fails, that means it needs to be set with a new one. The UsdUndoStateDelegate is stateless and doesn't need to be shared among layers.

}

void UsdUndoManager::addInverse(InvertFunc func)
Expand Down