-
Notifications
You must be signed in to change notification settings - Fork 202
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
Changes from 1 commit
120ae47
2981cca
a87fc0b
677db40
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,9 +29,16 @@ UsdUndoManager& UsdUndoManager::instance() | |
return undoManager; | ||
} | ||
|
||
void UsdUndoManager::trackLayerStates(const SdfLayerHandle& layer) | ||
void UsdUndoManager::trackStatesOnNewStage(const SdfLayerHandle& layer) | ||
{ | ||
layer->SetStateDelegate(UsdUndoStateDelegate::New()); | ||
_layerStateDelegate = TfCreateRefPtr(new UsdUndoStateDelegate); | ||
|
||
layer->SetStateDelegate(_layerStateDelegate); | ||
} | ||
|
||
void UsdUndoManager::trackStatesOnEditTargetChange(const SdfLayerHandle& layer) | ||
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. I'm a bit perplexed here. If we set a new state delegate on layer creation, then why do we have to set it on edit target change? Is it because of initialization order and the fact that certain layers may have been created before the UsdUndoManager starts tracking changes? 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. Every time we change the target edit layer, UsdUndoStateDelegate::_OnSetLayer is invoked where it We do need to call layer->SetStateDelegate() when we switch between layers otherwise how would the layer know what state delegate needs to use? Notice that in trackStatesOnEditTargetChange, I am only passing the _layerStateDelegate object that was created on stage set. More than one layer needs to share the same StateDelegate .
|
||
{ | ||
layer->SetStateDelegate(_layerStateDelegate); | ||
} | ||
|
||
void UsdUndoManager::addInverse(InvertFunc func) | ||
|
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.
Why do we save this as a data member? Since the UsdUndoManager is a singleton, doesn't that mean that more than one layer can share the same UsdUndoStateDelegate?
Thinking out loud here, could it be that the UsdUndoManager should track a set of layers, and when it sees one that isn't in its set, whether than be through a layer creation notification or an edit target change notification, it will give the unknown layer a newly-created UsdUndoStateDelegate, then will add the layer to its set of known 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 main reason I need to save _layerStateDelegate as a data member is for undo/redo purposes between layers itself.
Exactly, more than one layer can share the same UsdUndoStateDelegate in a same stage.
Let's have a chat around this. I would like to understand this approach better.