Skip to content

Commit eaf89e2

Browse files
authored
Merge pull request #2371 from Autodesk/t_bailp/MAYA-123016/clear-stage-reset-outliner
MAYA-123016 stage clear now resets the outliner
2 parents b6960e6 + 1a15a26 commit eaf89e2

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

lib/mayaUsd/utils/stageCache.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <pxr/usd/usdGeom/tokens.h>
2626

2727
#include <maya/MFileIO.h>
28+
#include <maya/MGlobal.h>
2829
#include <maya/MSceneMessage.h>
2930

3031
#include <map>
@@ -57,6 +58,22 @@ struct _OnSceneResetListener : public TfWeakBase
5758
}
5859
};
5960

61+
void clearMayaAttributeEditor()
62+
{
63+
// When a stage is deleted, the attribute editor could still refer to prims
64+
// that were on that stage. If the attribute editor is collapsed, then it
65+
// won't refresh itself and could later on try to access the prim.
66+
//
67+
// This happens when it receives a UFE notification that it thinks is about
68+
// the prim it is showing. This only happens if one re-stage the same file,
69+
// as the UFE notification will contain the same stage name and the same
70+
// prim path.
71+
//
72+
// To avoid crashes, we refresh the attribute editor templates when the
73+
// stages get cleared.
74+
MGlobal::executeCommand("refreshEditorTemplates");
75+
}
76+
6077
} // anonymous namespace
6178

6279
/* static */
@@ -74,6 +91,7 @@ UsdStageCache& UsdMayaStageCache::Get(const bool loadAll)
7491
/* static */
7592
void UsdMayaStageCache::Clear()
7693
{
94+
clearMayaAttributeEditor();
7795
Get(true).Clear();
7896
Get(false).Clear();
7997
}
@@ -88,6 +106,8 @@ size_t UsdMayaStageCache::EraseAllStagesWithRootLayerPath(const std::string& lay
88106
return erasedStages;
89107
}
90108

109+
clearMayaAttributeEditor();
110+
91111
erasedStages += Get(true).EraseAll(rootLayer);
92112
erasedStages += Get(false).EraseAll(rootLayer);
93113

0 commit comments

Comments
 (0)