Skip to content

Commit

Permalink
Merge pull request #1675 from Autodesk/t_bailp/MAYA-113559/prevent-st…
Browse files Browse the repository at this point in the history
…ae-attr-access-crash

MAYA-113559 prevent crash when accessing a stale attribute from Python
  • Loading branch information
Krystian Ligenza authored Sep 7, 2021
2 parents 325074b + 82896d1 commit ff41eb9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/mayaUsd/ufe/UsdAttribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ template <typename T> bool setUsdAttr(const PXR_NS::UsdAttribute& attr, const T&
// Therefore, we have implemented an attribute change block notification of
// our own in the StagesSubject, which we invoke here, so that only a
// single UFE attribute changed notification is generated.
if (!attr.IsValid())
return false;

MayaUsd::ufe::AttributeChangedNotificationGuard guard;
std::string errMsg;
bool isSetAttrAllowed = MayaUsd::ufe::isAttributeEditAllowed(attr, &errMsg);
Expand All @@ -96,7 +99,7 @@ PXR_NS::UsdTimeCode getCurrentTime(const Ufe::SceneItem::Ptr& item)
std::string
getUsdAttributeValueAsString(const PXR_NS::UsdAttribute& attr, const PXR_NS::UsdTimeCode& time)
{
if (!attr.HasValue())
if (!attr.IsValid() || !attr.HasValue())
return std::string();

PXR_NS::VtValue v;
Expand All @@ -118,7 +121,7 @@ getUsdAttributeValueAsString(const PXR_NS::UsdAttribute& attr, const PXR_NS::Usd
template <typename T, typename U>
U getUsdAttributeVectorAsUfe(const PXR_NS::UsdAttribute& attr, const PXR_NS::UsdTimeCode& time)
{
if (!attr.HasValue())
if (!attr.IsValid() || !attr.HasValue())
return U();

PXR_NS::VtValue vt;
Expand Down

0 comments on commit ff41eb9

Please sign in to comment.