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-128460 - undoing rename of prim causes prim's icon to change to def #2965

Merged

Conversation

seando-adsk
Copy link
Collaborator

MAYA-128460 - undoing the rename of a prim causes prim's icon to change to a def

  • For undo send the correct (new) prim in the Ufe notification.
  • Refactor undo/redo into common helper method.

…ge to a def

* For undo send the correct (new) prim in the Ufe notification.
* Refactor undo/redo into common helper method.
Comment on lines 195 to 201
void renameHelper(
PXR_NS::UsdStageWeakPtr stage,
const UsdSceneItem::Ptr& ufeSrcItem,
const Ufe::Path& srcPath,
UsdSceneItem::Ptr& ufeDstItem,
const Ufe::Path& dstPath,
const std::string& newName)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added new helper method for both undo and redo to avoid code duplication.

@@ -190,67 +192,63 @@ static void doUsdRename(
applyToAllPrimSpecs(prim, renameFunc);
}

void UsdUndoRenameCommand::renameRedo()
void renameHelper(
PXR_NS::UsdStageWeakPtr stage,
Copy link
Collaborator

Choose a reason for hiding this comment

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

While unlikely, a weak pointer could become invalid at any time. Also, it could be passed as const &. So i'd suggest using a const UsdStagePtr& here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Right good point.

// stale.
const UsdPrim prim = _stage->GetPrimAtPath(_ufeDstItem->prim().GetPath());
const std::string newName = _ufeSrcItem->prim().GetName();
const Ufe::Path srcPath = _ufeSrcItem->path();
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think scene item return teh path by ref, so this could be a &, to verify.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point, changed to auto so we don't need to worry about return type.

if (_ufeDstItem->prim().GetPath() == defaultPrimPath) {
_stage->SetDefaultPrim(_ufeSrcItem->prim());
}
const Ufe::Path srcPath = _ufeDstItem->path();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comment as above, could be const&

pierrebai-adsk
pierrebai-adsk previously approved these changes Mar 23, 2023
Copy link
Collaborator

@pierrebai-adsk pierrebai-adsk left a comment

Choose a reason for hiding this comment

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

Minor tweaks possible, otherwise LGTM.

pierrebai-adsk
pierrebai-adsk previously approved these changes Mar 23, 2023
Copy link
Collaborator

@pierrebai-adsk pierrebai-adsk left a comment

Choose a reason for hiding this comment

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

LGTM

@seando-adsk seando-adsk added the ufe-usd Related to UFE-USD plugin in Maya-Usd label Mar 24, 2023
…ge to a def

* clang-format fix (darn trailing space).
@seando-adsk seando-adsk added the ready-for-merge Development process is finished, PR is ready for merge label Mar 24, 2023
@seando-adsk seando-adsk merged commit b1b147d into dev Mar 24, 2023
@seando-adsk seando-adsk deleted the donnels/MAYA-128460/undo_rename_of_prim_causing_def_icon branch March 24, 2023 17:09
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 ufe-usd Related to UFE-USD plugin in Maya-Usd
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants