Skip to content

Commit

Permalink
Merge pull request #1039 from Autodesk/donnels/MAYA-107303/crash_with…
Browse files Browse the repository at this point in the history
…_multiple_ufe_items_in_single_string

MAYA-107303 - UFE: crash (debug only) with multiple UFE items in single string
  • Loading branch information
Krystian Ligenza authored Jan 6, 2021
2 parents d379bfc + 18aba71 commit c39e3f8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 19 deletions.
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 @@ -42,7 +42,6 @@ set(TEST_SCRIPT_FILES
testUsdExportSkeleton.py
testUsdExportStripNamespaces.py
testUsdExportStroke.py
testUsdExportUVTransforms.py
testUsdExportVisibilityDefault.py
testUsdImportCamera.py
testUsdImportColorSets.py
Expand Down Expand Up @@ -73,6 +72,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()

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

0 comments on commit c39e3f8

Please sign in to comment.