Skip to content

Commit

Permalink
HYDRA-686 : Make MayaHydraSceneIndex manual cleanup call its destructor
Browse files Browse the repository at this point in the history
  • Loading branch information
debloip-adsk committed Aug 26, 2024
1 parent 6961055 commit 831d967
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 15 deletions.
13 changes: 3 additions & 10 deletions lib/mayaHydra/hydraExtensions/sceneIndex/mayaHydraSceneIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,16 +476,6 @@ MayaHydraSceneIndex::MayaHydraSceneIndex(
}

MayaHydraSceneIndex::~MayaHydraSceneIndex()
{
//If you get a crash in a callback with a nullptr for _sceneIndex,
// it may be due to the fact that the _sceneIndex pointer has been nulled as its ref count reached 0 but the destructor is still being called.
//You should call RemoveCallbacksAndDeleteAdapters(); before the destructor is called.

// Remove our pick handler from the pick handler registry.
TF_AXIOM(MayaHydra::PickHandlerRegistry::Instance().Unregister(_rprimPath));
}

void MayaHydraSceneIndex::RemoveCallbacksAndDeleteAdapters()
{
//Remove global materials
if (_mayaDefaultMaterialFallback.IsHolding<HdMaterialNetworkMap>()){
Expand Down Expand Up @@ -513,6 +503,9 @@ void MayaHydraSceneIndex::RemoveCallbacksAndDeleteAdapters()
_materialAdapters.clear();
_cameraAdapters.clear();
_renderItemsAdaptersFast.clear();

// Remove our pick handler from the pick handler registry.
TF_AXIOM(MayaHydra::PickHandlerRegistry::Instance().Unregister(_rprimPath));
}

void MayaHydraSceneIndex::HandleCompleteViewportScene(const MDataServerOperation::MViewportScene& scene, MFrameContext::DisplayStyle ds)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,6 @@ class MAYAHYDRALIB_API MayaHydraSceneIndex : public HdRetainedSceneIndex, public

~MayaHydraSceneIndex();

//Call this before the destructor is called.
void RemoveCallbacksAndDeleteAdapters();

// ------------------------------------------------------------------------
// Maya Hydra scene producer implementations
// Propogate scene changes from Maya to Hydra
Expand Down
2 changes: 0 additions & 2 deletions lib/mayaHydra/mayaPlugin/renderOverride.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,6 @@ void MtohRenderOverride::_SetRenderPurposeTags(const MayaHydraParams& delegatePa
void MtohRenderOverride::_ClearMayaHydraSceneIndex()
{
_renderIndexProxy->RemoveSceneIndex(_mayaHydraSceneIndex);
_mayaHydraSceneIndex->RemoveCallbacksAndDeleteAdapters(); //This should be called before calling _sceneIndex.Reset(); which will call the destructor if the ref count reaches 0
_mayaHydraSceneIndex.Reset();
}

Expand Down Expand Up @@ -1063,7 +1062,6 @@ void MtohRenderOverride::ClearHydraResources(bool fullReset)
#ifdef CODE_COVERAGE_WORKAROUND
// Leak the Maya scene index, as its base class HdRetainedSceneIndex
// destructor crashes under Windows clang code coverage build.
_mayaHydraSceneIndex->RemoveCallbacksAndDeleteAdapters();
_mayaHydraSceneIndex.Reset();
#else
_ClearMayaHydraSceneIndex();
Expand Down

0 comments on commit 831d967

Please sign in to comment.