Skip to content

Commit

Permalink
MAYA-129309 fixing saving the pinned stage
Browse files Browse the repository at this point in the history
- Make the Maya session state resgister and unreguster its Maya notification on creation and deletion.
- No longer de-regiuster the notifictions whne the layer manager window is created or closed.
- That was causing the session state to not save the pinned stage because the layer manager would get destroyed before the pinned stage was saved and the notifications would no longer be received.
- When switching pinned stage, mark the Maya scene as dirty.
  • Loading branch information
pierrebai-adsk committed May 31, 2023
1 parent ee64371 commit 97ee907
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
10 changes: 9 additions & 1 deletion lib/mayaUsd/nodes/layerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,15 @@ void LayerDatabase::refreshProxiesToSave()
}
}

void LayerDatabase::setSelectedStage(const std::string& stage) { _selectedStage = stage; }
void LayerDatabase::setSelectedStage(const std::string& stage)
{
if (_selectedStage == stage)
return;

_selectedStage = stage;
// Mark the scene as modified.
MGlobal::executeCommand("file -modified 1");
}

std::string LayerDatabase::getSelectedStage() const { return _selectedStage; }

Expand Down
4 changes: 1 addition & 3 deletions lib/usd/ui/layerEditor/mayaLayerEditorWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,14 @@ MayaLayerEditorWindow::MayaLayerEditorWindow(const char* panelName, QWidget* par
&MayaLayerEditorWindow::onClearUIOnSceneReset);
}

MayaLayerEditorWindow::~MayaLayerEditorWindow() { _sessionState.unregisterNotifications(); }
MayaLayerEditorWindow::~MayaLayerEditorWindow() { }

void MayaLayerEditorWindow::onClearUIOnSceneReset()
{
// I'm not sure if I need this, but in earlier prototypes it was
// safer to delete the entire UI and re-recreate it on scene changes
// to release all the proxies
LayerTreeModel::suspendUsdNotices(true);
_sessionState.unregisterNotifications();
setCentralWidget(nullptr);
delete _layerEditor;

Expand All @@ -129,7 +128,6 @@ void MayaLayerEditorWindow::onCreateUI()
_layerEditor = new LayerEditorWidget(_sessionState, this);
setCentralWidget(_layerEditor);
_layerEditor->show();
_sessionState.registerNotifications();

connect(
treeView(),
Expand Down
8 changes: 7 additions & 1 deletion lib/usd/ui/layerEditor/mayaSessionState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,17 @@ MayaSessionState::MayaSessionState()
if (MGlobal::optionVarExists(AUTO_HIDE_OPTION_VAR)) {
_autoHideSessionLayer = MGlobal::optionVarIntValue(AUTO_HIDE_OPTION_VAR) != 0;
}

registerNotifications();
}

MayaSessionState::~MayaSessionState()
{
//
try {
unregisterNotifications();
} catch (const std::exception&) {
// Ignore errors in destructor.
}
}

void MayaSessionState::setStageEntry(StageEntry const& inEntry)
Expand Down
6 changes: 3 additions & 3 deletions lib/usd/ui/layerEditor/mayaSessionState.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ class MayaSessionState
void clearUIOnSceneResetSignal();

public:
void registerNotifications();
void unregisterNotifications();

// get the stage and proxy name for a path
static bool getStageEntry(StageEntry* out_stageEntry, const MString& shapePath);

protected:
void registerNotifications();
void unregisterNotifications();

// maya callback handers
static void proxyShapeAddedCB(MObject& node, void* clientData);
static void proxyShapeRemovedCB(MObject& node, void* clientData);
Expand Down

0 comments on commit 97ee907

Please sign in to comment.