-
Notifications
You must be signed in to change notification settings - Fork 203
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
EMSUSD-255 Fixes an issue in Layer Editor where Save All icon was not functioning properly. #3222
Merged
seando-adsk
merged 2 commits into
dev
from
azharia/EMSUSD-255/Fixes-LayerEditor-SaveAll-Functionality
Jul 18, 2023
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -504,7 +504,10 @@ void SaveLayersDialog::buildDialog(const QString& msg1, const QString& msg2) | |
for (auto iter = _anonLayerInfos.crbegin(); iter != _anonLayerInfos.crend(); ++iter) { | ||
// Note: the row adds itself as a children of the dialog, so it will be deleted | ||
// when the dialog closes. | ||
new SaveLayerPathRow(this, anonLayout, gridRow++, (*iter)); | ||
auto saveLayerPathRow = new SaveLayerPathRow(this, anonLayout, gridRow++, (*iter)); | ||
// Note: We keep track of the row data so that it can be used when saving layers without | ||
// having to iterate over SaveLayersDialog's entire layout. | ||
_saveLayerPathRows.push_back(saveLayerPathRow); | ||
} | ||
|
||
_anonLayersWidget = new QWidget(); | ||
|
@@ -632,13 +635,8 @@ QString SaveLayersDialog::buildTooltipForLayer(SdfLayerRefPtr layer) | |
|
||
QWidget* SaveLayersDialog::findEntry(SdfLayerRefPtr key) | ||
{ | ||
if (!_anonLayersWidget || !_anonLayersWidget->layout()) { | ||
return nullptr; | ||
} | ||
|
||
QLayout* anonLayout = _anonLayersWidget->layout(); | ||
for (int i = 0, count = anonLayout->count(); i < count; ++i) { | ||
auto row = dynamic_cast<SaveLayerPathRow*>(anonLayout->itemAt(i)->widget()); | ||
for (int i = 0, count = _saveLayerPathRows.size(); i < count; ++i) { | ||
auto row = dynamic_cast<SaveLayerPathRow*>(_saveLayerPathRows[i]); | ||
if (row && row->_layerInfo.layer == key) { | ||
return row; | ||
} | ||
|
@@ -649,13 +647,8 @@ QWidget* SaveLayersDialog::findEntry(SdfLayerRefPtr key) | |
|
||
void SaveLayersDialog::forEachEntry(const std::function<void(QWidget*)>& func) | ||
{ | ||
if (!_anonLayersWidget || !_anonLayersWidget->layout()) { | ||
return; | ||
} | ||
|
||
QLayout* anonLayout = _anonLayersWidget->layout(); | ||
for (int i = 0, count = anonLayout->count(); i < count; ++i) { | ||
func(anonLayout->itemAt(i)->widget()); | ||
for (int i = 0, count = _saveLayerPathRows.size(); i < count; ++i) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, the order of iteration is from top layer to bottom |
||
func(_saveLayerPathRows[i]); | ||
} | ||
} | ||
|
||
|
@@ -669,41 +662,36 @@ void SaveLayersDialog::onSaveAll() | |
_problemLayers.clear(); | ||
_emptyLayers.clear(); | ||
|
||
// The anonymous layer section in the dialog can be empty. | ||
if (nullptr != _anonLayersWidget) { | ||
QLayout* anonLayout = _anonLayersWidget->layout(); | ||
// Note: must start from the end so that sub-layers are saved before their parent. | ||
for (int count = anonLayout->count(), i = count - 1; i >= 0; --i) { | ||
auto row = dynamic_cast<SaveLayerPathRow*>(anonLayout->itemAt(i)->widget()); | ||
if (!row || !row->_layerInfo.layer) | ||
continue; | ||
|
||
QString absolutePath = row->getAbsolutePath(); | ||
if (!absolutePath.isEmpty()) { | ||
auto sdfLayer = row->_layerInfo.layer; | ||
auto parent = row->_layerInfo.parent; | ||
auto stage = row->_layerInfo.stage; | ||
|
||
MayaUsd::utils::PathInfo pathInfo; | ||
pathInfo.absolutePath = absolutePath.toStdString(); | ||
pathInfo.savePathAsRelative = row->needToSaveAsRelative(); | ||
if (pathInfo.savePathAsRelative && parent._layerParent | ||
&& parent._layerParent->IsAnonymous()) { | ||
pathInfo.customRelativeAnchor = row->calculateParentLayerDir(); | ||
} | ||
// Note: must start from the end so that sub-layers are saved before their parent. | ||
for (int count = _saveLayerPathRows.size(), i = count - 1; i >= 0; --i) { | ||
auto row = dynamic_cast<SaveLayerPathRow*>(_saveLayerPathRows[i]); | ||
if (!row || !row->_layerInfo.layer) | ||
continue; | ||
|
||
QString absolutePath = row->getAbsolutePath(); | ||
if (!absolutePath.isEmpty()) { | ||
auto sdfLayer = row->_layerInfo.layer; | ||
auto parent = row->_layerInfo.parent; | ||
auto stage = row->_layerInfo.stage; | ||
|
||
MayaUsd::utils::PathInfo pathInfo; | ||
pathInfo.absolutePath = absolutePath.toStdString(); | ||
pathInfo.savePathAsRelative = row->needToSaveAsRelative(); | ||
if (pathInfo.savePathAsRelative && parent._layerParent | ||
&& parent._layerParent->IsAnonymous()) { | ||
pathInfo.customRelativeAnchor = row->calculateParentLayerDir(); | ||
} | ||
|
||
auto newLayer | ||
= MayaUsd::utils::saveAnonymousLayer(stage, sdfLayer, pathInfo, parent); | ||
if (newLayer) { | ||
_newPaths.append(QString::fromStdString(sdfLayer->GetDisplayName())); | ||
_newPaths.append(absolutePath); | ||
} else { | ||
_problemLayers.append(QString::fromStdString(sdfLayer->GetDisplayName())); | ||
_problemLayers.append(absolutePath); | ||
} | ||
auto newLayer = MayaUsd::utils::saveAnonymousLayer(stage, sdfLayer, pathInfo, parent); | ||
if (newLayer) { | ||
_newPaths.append(QString::fromStdString(sdfLayer->GetDisplayName())); | ||
_newPaths.append(absolutePath); | ||
} else { | ||
_emptyLayers.append(row->layerDisplayName()); | ||
_problemLayers.append(QString::fromStdString(sdfLayer->GetDisplayName())); | ||
_problemLayers.append(absolutePath); | ||
} | ||
} else { | ||
_emptyLayers.append(row->layerDisplayName()); | ||
} | ||
} | ||
|
||
|
@@ -719,25 +707,22 @@ bool SaveLayersDialog::okToSave() | |
QMap<QString, int> alreadySeenPaths; | ||
QStringList existingFiles; | ||
|
||
// The anonymous layer section in the dialog can be empty. | ||
if (nullptr != _anonLayersWidget) { | ||
QLayout* anonLayout = _anonLayersWidget->layout(); | ||
for (int i = 0, count = anonLayout->count(); i < count; ++i) { | ||
auto row = dynamic_cast<SaveLayerPathRow*>(anonLayout->itemAt(i)->widget()); | ||
if (nullptr == row) | ||
continue; | ||
|
||
QString path = row->getAbsolutePath(); | ||
if (!path.isEmpty()) { | ||
if (alreadySeenPaths.count(path) > 0) { | ||
alreadySeenPaths[path] += 1; | ||
} else { | ||
alreadySeenPaths[path] = 1; | ||
} | ||
QFileInfo fInfo(path); | ||
if (fInfo.exists()) { | ||
existingFiles.append(path); | ||
} | ||
for (int count = _saveLayerPathRows.size(), i = count - 1; i >= 0; --i) { | ||
auto row = dynamic_cast<SaveLayerPathRow*>(_saveLayerPathRows[i]); | ||
if (!row || !row->_layerInfo.layer) | ||
continue; | ||
|
||
QString path = row->getAbsolutePath(); | ||
|
||
if (!path.isEmpty()) { | ||
if (alreadySeenPaths.count(path) > 0) { | ||
alreadySeenPaths[path] += 1; | ||
} else { | ||
alreadySeenPaths[path] = 1; | ||
} | ||
QFileInfo fInfo(path); | ||
if (fInfo.exists()) { | ||
existingFiles.append(path); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kept the order of iteration the same as before, Although in this case it shouldn't matter as it is only picking one item.