Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spinell/maya 110157/clearing mutiple layer crash #1274

Merged
merged 3 commits into from
Mar 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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