Skip to content

Commit

Permalink
Merge pull request #3130 from Autodesk/bailp/MAYA-129309/pin-stage-di…
Browse files Browse the repository at this point in the history
…rty-scene

MAYA-129309 fixing saving the pinned stage
  • Loading branch information
seando-adsk authored May 31, 2023
2 parents a947141 + 97ee907 commit 590ee8c
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 590ee8c

Please sign in to comment.