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

EMSUSD-1788 fix warnings about the layer manager attribute #3994

Merged
merged 1 commit into from
Nov 14, 2024
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
13 changes: 5 additions & 8 deletions lib/mayaUsd/nodes/layerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ class LayerDatabase : public TfWeakBase
std::string getSelectedStage() const;

bool saveLayerManagerSelectedStage();
bool loadLayerManagerSelectedStage(MayaUsdProxyShapeBase* forProxyShape);
bool loadLayerManagerSelectedStage(MayaUsd::LayerManager& layerManager);

SdfLayerHandle findLayer(std::string identifier) const;

Expand Down Expand Up @@ -702,14 +702,11 @@ bool LayerDatabase::saveLayerManagerSelectedStage()
return true;
}

bool LayerDatabase::loadLayerManagerSelectedStage(MayaUsdProxyShapeBase* forProxyShape)
bool LayerDatabase::loadLayerManagerSelectedStage(MayaUsd::LayerManager& layerManager)
{
MayaUsd::LayerManager* lm = findNode(forProxyShape);
if (!lm)
return false;

MStatus status;
MPlug selectedStagePlug(lm->thisMObject(), lm->selectedStage);

MPlug selectedStagePlug(layerManager.thisMObject(), layerManager.selectedStage);
setSelectedStage(selectedStagePlug.asString(MDGContext::fsNormal, &status).asChar());

return status;
Expand Down Expand Up @@ -1233,7 +1230,7 @@ void LayerDatabase::loadLayersPostRead(MayaUsdProxyShapeBase* forProxyShape)
}
}

LayerDatabase::instance().loadLayerManagerSelectedStage(forProxyShape);
LayerDatabase::instance().loadLayerManagerSelectedStage(*lm);

if (!_isSavingMayaFile)
removeManagerNode(lm, forProxyShape);
Expand Down
17 changes: 13 additions & 4 deletions lib/mayaUsd/nodes/proxyShapeBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1981,25 +1981,34 @@ void MayaUsdProxyShapeBase::getDrawPurposeToggles(

MayaUsd::LayerManager* MayaUsdProxyShapeBase::getLayerManager()
{
// Note: don't use the CHECK_MSTATUS macros because it is expected to not
// find the layer manager atribute or layer manager UUID when loading
// old scenes or recomputing the proxy shape after the layer manager
// node has been deleted. So errors in this function are not hard errors.

MStatus localStatus;

MDataBlock dataBlock = forceCache();
MDataHandle layerManagerData = dataBlock.inputValue(layerManagerAttr, &localStatus);
CHECK_MSTATUS_AND_RETURN(localStatus, nullptr);
if (!localStatus)
return nullptr;

if (layerManagerData.asString().length() <= 0)
return nullptr;

MUuid layerManagerUuid(layerManagerData.asString(), &localStatus);
CHECK_MSTATUS_AND_RETURN(localStatus, nullptr);
if (!localStatus)
return nullptr;

MSelectionList selection;
localStatus = selection.add(layerManagerUuid);
CHECK_MSTATUS_AND_RETURN(localStatus, nullptr);
if (!localStatus)
return nullptr;

MObject layerManagerObj;
localStatus = selection.getDependNode(0, layerManagerObj);
CHECK_MSTATUS_AND_RETURN(localStatus, nullptr);
if (!localStatus)
return nullptr;

MFnDependencyNode depNode;
if (!depNode.setObject(layerManagerObj))
Expand Down