-
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
Fix edit router parent test. #2068
Conversation
@@ -24,7 +24,6 @@ | |||
|
|||
from pxr import Sdf, Tf | |||
|
|||
from functools import partial |
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.
Removed dead code.
@@ -63,6 +63,9 @@ void UsdSetMatrix4dUndoableCommand::executeUndoBlock() | |||
// transform stack, but not for a fallback Maya transform stack, and | |||
// both can be edited by this command. | |||
auto t3d = Ufe::Transform3d::editTransform3d(sceneItem()); | |||
if (!TF_VERIFY(t3d)) { |
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.
Missing nullptr check was causing crash.
// Return built-in default edit routers. | ||
EditRouters editRouterDefaults(); | ||
EditRouters defaultEditRouters(); |
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.
Renamed for consistency. All other edit router-related functions end with the suffix "editRouter", so for familiarity renamed this one to match.
lib/mayaUsd/utils/editRouter.h
Outdated
// the currently-registered edit router. Returns false if no such default | ||
// exists. | ||
MAYAUSD_CORE_PUBLIC | ||
bool registerDefaultEditRouter(const PXR_NS::TfToken& operation); |
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.
Added a way to restore the default, which the testParentCmd must do, otherwise it leaves the mayapy process with the test edit router, which causes other parenting tests to fail.
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.
How about we call it restoreDefaultEditRouter? I needed to read the understand what this method is supposed to do.
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.
Works for me.
|
||
def childrenNames(children): | ||
return [str(child.path().back()) for child in children] | ||
|
||
def firstSubLayer(context, routingData): |
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.
Moved into test itself.
layer = Sdf.Layer.Find(layerId) | ||
# Make sure the destination exists in the target layer, otherwise | ||
# SdfCopySpec will error. | ||
Sdf.JustCreatePrimInLayer(layer, prim.GetPath()) |
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.
This is the crucial change in the test: the destination layer is completely empty, but SdfCopySpec requires a destination prim. Just create an empty prim in the destination layer.
mayaUsd.lib.registerEditRouter('parent', firstSubLayer) | ||
|
||
# Check that layer B is empty. |
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.
Various test improvements: ensure the destination layer is empty before parenting, that it has the expected over's after parenting, etc.
test/lib/ufe/testParentCmd.py
Outdated
'over "C"\n{\n def Xform "B"\n {\n }\n}') | ||
|
||
# Restore default edit router. | ||
mayaUsd.lib.registerDefaultEditRouter('parent') |
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.
Restore default edit router on test exit, otherwise other parenting tests will fail.
@@ -74,4 +74,9 @@ void wrapEditRouter() | |||
return MayaUsd::registerEditRouter( | |||
operation, std::make_shared<PyEditRouter>(editRouter)); | |||
}); | |||
|
|||
def( | |||
"restoreDefaultEditRouter", +[](const PXR_NS::TfToken& operation) { |
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 not just setting the address of the function to call instead of creating a lambda function that is calling the function directly?
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.
Quite right! I just mindlessly copy-pasted the code above, there's no need for a lambda in this case, good catch.
No description provided.