Skip to content

Commit

Permalink
Merge pull request #2882 from Autodesk/azharia/MAYA-124103/export-all…
Browse files Browse the repository at this point in the history
…-memory-leak-fix

Releases the memory a data handle is holding onto when exporting meshes.
  • Loading branch information
seando-adsk authored Mar 2, 2023
2 parents d075edb + 0a5b709 commit 24c79ad
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/mayaUsd/fileio/utils/meshWriteUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1408,8 +1408,8 @@ MStatus UsdMayaMeshWriteUtils::exportComponentTags(UsdGeomMesh& primSchema, MObj
MPlug outShp = depNodeFn.findPlug("outMesh", &status);
CHECK_MSTATUS_AND_RETURN_IT(status);

MDataHandle geomDataHandle = outShp.asMDataHandle();
MObject geomObj = geomDataHandle.data();
auto outShpHolder = UsdMayaUtil::GetPlugDataHandle(outShp);
MObject geomObj = outShpHolder->GetDataHandle().data();
if (geomObj.hasFn(MFn::kGeometryData)) {
TfToken componentTagFamilyName("componentTag");
MFnGeometryData fnGeomData(geomObj);
Expand Down
5 changes: 4 additions & 1 deletion lib/mayaUsd/render/vp2RenderDelegate/mayaPrimCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include <pxr/usdImaging/usdImaging/delegate.h>

#ifdef MAYA_HAS_DISPLAY_LAYER_API
#include <mayaUsd/utils/util.h>

#include <maya/MFnDisplayLayer.h>
#include <maya/MFnDisplayLayerManager.h>
#include <maya/MObjectArray.h>
Expand Down Expand Up @@ -702,7 +704,8 @@ void MayaUsdRPrim::_ProcessDisplayLayerModes(
}

if (useRGBColors.asBool()) {
const float3& rgbColor = colorRGB.asMDataHandle().asFloat3();
auto colorRGBHolder = UsdMayaUtil::GetPlugDataHandle(colorRGB);
const float3& rgbColor = colorRGBHolder->GetDataHandle().asFloat3();
displayLayerModes._wireframeColorIndex = -1;
displayLayerModes._wireframeColorRGBA
= MColor(rgbColor[0], rgbColor[1], rgbColor[2], colorA.asFloat());
Expand Down
6 changes: 4 additions & 2 deletions lib/usd/translators/meshWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,9 +567,11 @@ bool PxrUsdTranslators_MeshWriter::writeMeshAttrs(
MPlug plgBlendShapeInput = plgBlendShapeInputs.elementByLogicalIndex(idxGeo);
MPlug plgBlendShapeInputGeometry
= UsdMayaUtil::FindChildPlugWithName(plgBlendShapeInput, "inputGeometry");
auto plgBlendShapeInputGeometryHolder
= UsdMayaUtil::GetPlugDataHandle(plgBlendShapeInputGeometry);
MDataHandle dhInputGeo
= plgBlendShapeInputGeometry
.asMDataHandle(); // NOTE: (yliangsiew) This should be the pref mesh.
= plgBlendShapeInputGeometryHolder->GetDataHandle(); // NOTE: (yliangsiew) This
// should be the pref mesh.
TF_VERIFY(dhInputGeo.type() == MFnData::kMesh);
MObject inputGeo = dhInputGeo.asMesh();
TF_VERIFY(inputGeo.hasFn(MFn::kMesh));
Expand Down

0 comments on commit 24c79ad

Please sign in to comment.