Skip to content

Commit

Permalink
Merge pull request #2371 from Autodesk/t_bailp/MAYA-123016/clear-stag…
Browse files Browse the repository at this point in the history
…e-reset-outliner

MAYA-123016 stage clear now resets the outliner
  • Loading branch information
seando-adsk authored May 25, 2022
2 parents b6960e6 + 1a15a26 commit eaf89e2
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lib/mayaUsd/utils/stageCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <pxr/usd/usdGeom/tokens.h>

#include <maya/MFileIO.h>
#include <maya/MGlobal.h>
#include <maya/MSceneMessage.h>

#include <map>
Expand Down Expand Up @@ -57,6 +58,22 @@ struct _OnSceneResetListener : public TfWeakBase
}
};

void clearMayaAttributeEditor()
{
// When a stage is deleted, the attribute editor could still refer to prims
// that were on that stage. If the attribute editor is collapsed, then it
// won't refresh itself and could later on try to access the prim.
//
// This happens when it receives a UFE notification that it thinks is about
// the prim it is showing. This only happens if one re-stage the same file,
// as the UFE notification will contain the same stage name and the same
// prim path.
//
// To avoid crashes, we refresh the attribute editor templates when the
// stages get cleared.
MGlobal::executeCommand("refreshEditorTemplates");
}

} // anonymous namespace

/* static */
Expand All @@ -74,6 +91,7 @@ UsdStageCache& UsdMayaStageCache::Get(const bool loadAll)
/* static */
void UsdMayaStageCache::Clear()
{
clearMayaAttributeEditor();
Get(true).Clear();
Get(false).Clear();
}
Expand All @@ -88,6 +106,8 @@ size_t UsdMayaStageCache::EraseAllStagesWithRootLayerPath(const std::string& lay
return erasedStages;
}

clearMayaAttributeEditor();

erasedStages += Get(true).EraseAll(rootLayer);
erasedStages += Get(false).EraseAll(rootLayer);

Expand Down

0 comments on commit eaf89e2

Please sign in to comment.