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-107303 - UFE: crash (debug only) with multiple UFE items in single string #1039

Merged
Show file tree
Hide file tree
Changes from all commits
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
16 changes: 14 additions & 2 deletions lib/mayaUsd/ufe/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ template <> struct iterator_traits<MStringArray::Iterator>
} // namespace std
#endif

namespace {
constexpr auto kIllegalUSDPath = "Illegal USD run-time path %s.";
}

namespace MAYAUSD_NS_DEF {
namespace ufe {

Expand Down Expand Up @@ -77,8 +81,12 @@ UsdPrim ufePathToPrim(const Ufe::Path& path)
// Assume that there are only two segments in the path, the first a Maya
// Dag path segment to the proxy shape, which identifies the stage, and
// the second the USD segment.
// When called we do not make any assumption on whether or not the
// input path is valid.
const Ufe::Path::Segments& segments = path.getSegments();
TEST_USD_PATH(segments, path);
if (!TF_VERIFY(segments.size() == 2, kIllegalUSDPath, path.string().c_str())) {
return UsdPrim();
}

UsdPrim prim;
if (auto stage = getStage(Ufe::Path(segments[0]))) {
Expand All @@ -89,8 +97,12 @@ UsdPrim ufePathToPrim(const Ufe::Path& path)

bool isRootChild(const Ufe::Path& path)
{
// When called we make the assumption that we are given a valid
// path and we are only testing whether or not we are a root child.
auto segments = path.getSegments();
TEST_USD_PATH(segments, path);
if (segments.size() != 2) {
TF_RUNTIME_ERROR(kIllegalUSDPath, path.string().c_str());
}
return (segments[1].size() == 1);
}

Expand Down
16 changes: 0 additions & 16 deletions lib/mayaUsd/ufe/private/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,6 @@ PXR_NAMESPACE_USING_DIRECTIVE
namespace MAYAUSD_NS_DEF {
namespace ufe {

//------------------------------------------------------------------------------
// Private globals and macros
//------------------------------------------------------------------------------
const std::string kIllegalUSDPath = "Illegal USD run-time path %s.";

#if !defined(NDEBUG)
#define TEST_USD_PATH(SEG, PATH) \
assert(SEG.size() == 2); \
if (SEG.size() != 2) \
TF_WARN(kIllegalUSDPath.c_str(), PATH.string().c_str());
#else
#define TEST_USD_PATH(SEG, PATH) \
if (SEG.size() != 2) \
TF_WARN(kIllegalUSDPath.c_str(), PATH.string().c_str());
#endif

//------------------------------------------------------------------------------
// Private helper functions
//------------------------------------------------------------------------------
Expand Down
10 changes: 9 additions & 1 deletion test/lib/usd/translators/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ set(TEST_SCRIPT_FILES
testUsdExportSkeleton.py
testUsdExportStripNamespaces.py
testUsdExportStroke.py
testUsdExportUVTransforms.py
testUsdExportVisibilityDefault.py
testUsdImportCamera.py
testUsdImportColorSets.py
Expand Down Expand Up @@ -72,6 +71,15 @@ set(TEST_SCRIPT_FILES
testUsdMayaAdaptorUndoRedo.py
)

if(BUILD_PXR_PLUGIN)
# This test uses the file "UsdExportUVTransforms.ma" which
# requires the plugin "pxrUsdPreviewSurface" that is built by the
# Pixar plugin.
list(APPEND TEST_SCRIPT_FILES
testUsdExportUVTransforms.py
)
endif()
Comment on lines +74 to +81
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I had built locally only the maya-usd plugin and got this test failing. Found it is because of the ma file it loads (there is another example of this).

Copy link

Choose a reason for hiding this comment

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

A better approach would be to port this test to use usdPreviewSurface node that is independent of Pixar plugin - see https://github.com/Autodesk/maya-usd/blob/dev/lib/usd/pxrUsdPreviewSurface/usdPreviewSurfacePlugin.cpp

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Let's do that in a separate PR. I copied this way of skipping the test from another place. So there are multiple tests that need to be ported.


if (BUILD_RFM_TRANSLATORS)
list(APPEND TEST_SCRIPT_FILES
testUsdExportRfMShaders.py
Expand Down