Skip to content

Commit

Permalink
Merge pull request #1274 from Autodesk/spinell/MAYA-110157/clearing_m…
Browse files Browse the repository at this point in the history
…utiple_layer_crash

Spinell/maya 110157/clearing mutiple layer crash
  • Loading branch information
Krystian Ligenza authored Mar 24, 2021
2 parents 4545f04 + 496a972 commit adef2db
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 21 deletions.
17 changes: 1 addition & 16 deletions lib/usd/ui/layerEditor/layerTreeItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,21 +394,6 @@ void LayerTreeItem::printLayer()
}
}

void LayerTreeItem::clearLayer()
{
MString title;
title.format(
StringResources::getAsMString(StringResources::kClearLayerTitle),
MQtUtil::toMString(text()));

MString desc;
desc.format(
StringResources::getAsMString(StringResources::kClearLayerConfirmMessage),
MQtUtil::toMString(text()));

if (confirmDialog(MQtUtil::toQString(title), MQtUtil::toQString(desc))) {
commandHook()->clearLayer(layer());
}
}
void LayerTreeItem::clearLayer() { commandHook()->clearLayer(layer()); }

} // namespace UsdLayerEditor
13 changes: 13 additions & 0 deletions lib/usd/ui/layerEditor/mayaLayerEditorWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,21 @@ void MayaLayerEditorWindow::printLayer()

void MayaLayerEditorWindow::clearLayer()
{
// Suspend usd notification while clearing and force a refresh after
// all layers are cleared. This is required because callMethodOnSelection()
// will loop on all selected layers and clear them one by one, If a refresh
// happen before callMethodOnSelection() finish to loop over the selected item,
// maya will crash because of a dangling pointer (All layer item are deleted
// during the refresh).
LayerTreeModel::suspendUsdNotices(true);

QString name = "Clear";
treeView()->callMethodOnSelection(name, &LayerTreeItem::clearLayer);

LayerTreeModel::suspendUsdNotices(false);

LayerTreeModel* model = treeView()->layerTreeModel();
model->forceRefresh();
}

void MayaLayerEditorWindow::selectPrimsWithSpec()
Expand Down
5 changes: 0 additions & 5 deletions lib/usd/ui/layerEditor/stringResources.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ const auto kAutoHideSessionLayer { create("kAutoHideSessionLayer", "Auto-Hid
const auto kBinary { create("kBinary", "Binary") };
const auto kConvertToRelativePath { create("kConvertToRelativePath", "Convert to Relative Path") };
const auto kCancel { create("kCancel", "Cancel") };
const auto kClearLayerTitle { create("kclearLayerTitle", "Clear \"^1s\"") };
const auto kClearLayerConfirmMessage { create("kClearLayerConfirmMessage",
"Are you sure you want to clear this layer?"
" \"^1s\" will remain in the Layer Editor"
" but all contents will be cleared, including sublayer paths.") };
const auto kCreate { create("kCreate", "Create") };
const auto kRevertToFileTitle { create("kRevertToFileTitle", "Revert to File \"^1s\"") };
const auto kRevertToFileMsg { create("kRevertToFileMsg", "Are you sure you want to revert \"^1s\" to its "
Expand Down

0 comments on commit adef2db

Please sign in to comment.