Skip to content

Commit

Permalink
Deadlock with AddTarget() of a relative path.
Browse files Browse the repository at this point in the history
Fixes issue #76.

(Internal change: 1662430)
  • Loading branch information
blevin authored and pixar-oss committed Oct 17, 2016
1 parent 3d698f1 commit 9abba3b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
7 changes: 7 additions & 0 deletions pxr/usd/lib/usd/instanceCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,13 @@ Usd_InstanceCache::IsPathMasterOrInMaster(const SdfPath& path)
if (path.IsEmpty()) {
return false;
}
if (!path.IsAbsolutePath()) {
// We require an absolute path because there is no way for us
// to walk to the root prim level from a relative path.
TF_CODING_ERROR("IsPathMasterOrInMaster() requires an absolute path "
"but was given <%s>", path.GetText());
return false;
}

SdfPath rootPath = path;
while (not rootPath.IsRootPrimPath()) {
Expand Down
2 changes: 1 addition & 1 deletion pxr/usd/lib/usd/instanceCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class Usd_InstanceCache : boost::noncopyable
void ProcessChanges(Usd_InstanceChanges* changes);

/// Returns true if an object at \p path is a master or in a
/// master.
/// master. \p path must be either an absolute path or empty.
static bool IsPathMasterOrInMaster(const SdfPath& path);

/// Returns the paths of all master prims for instance prim
Expand Down
13 changes: 9 additions & 4 deletions pxr/usd/lib/usd/relationship.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,16 @@ SdfPath
UsdRelationship::_GetTargetForAuthoring(const SdfPath &target,
std::string* whyNot) const
{
if (Usd_InstanceCache::IsPathMasterOrInMaster(target)) {
if (whyNot) {
*whyNot = "Cannot target a master or an object within a master.";
if (!target.IsEmpty()) {
SdfPath absTarget =
target.MakeAbsolutePath(GetPath().GetAbsoluteRootOrPrimPath());
if (Usd_InstanceCache::IsPathMasterOrInMaster(absTarget)) {
if (whyNot) {
*whyNot = "Cannot target a master or an object within a "
"master.";
}
return SdfPath();
}
return SdfPath();
}

UsdStage *stage = _GetStage();
Expand Down

0 comments on commit 9abba3b

Please sign in to comment.