Combination of CLI args results in jumbled layer order (fix #1644)

- The order is fixed because we now iterate a LayerList (a
  std::vector) instead of a SelectedLayers (a std::set)
- This can be an issue each time we iterate over a std::set (and
  SelectedLayers is a std::set) because it depends on the specific STL
  impl details (which vary depending on msvc/clang/gcc compiler).
- This fix iterates over layers, no matter if are visible or not
  (SelectedLayers::toLayerList() returns only browseable layers)
This commit is contained in:
David N Campo 2018-11-10 13:31:28 -03:00 committed by David Capello
parent 0c86d9bb5c
commit f6bb446031
5 changed files with 31 additions and 1 deletions

View File

@ -540,7 +540,7 @@ bool CliProcessor::openFile(Context* ctx, CliOpenFile& cof)
filter_layers(doc->sprite()->allLayers(), cof, filteredLayers);
if (cof.splitLayers) {
for (Layer* layer : filteredLayers) {
for (Layer* layer : filteredLayers.toAllLayersList()) {
SelectedLayers oneLayer;
oneLayer.insert(layer);

View File

@ -58,6 +58,26 @@ bool SelectedLayers::hasSameParent() const
return true;
}
LayerList SelectedLayers::toAllLayersList() const
{
LayerList output;
if (empty())
return output;
ASSERT(*begin());
ASSERT((*begin())->sprite());
for (Layer* layer = (*begin())->sprite()->firstLayer();
layer != nullptr;
layer = layer->getNext()) {
if (contains(layer))
output.push_back(layer);
}
return output;
}
LayerList SelectedLayers::toLayerList() const
{
LayerList output;

View File

@ -39,6 +39,7 @@ namespace doc {
bool contains(Layer* layer) const;
bool hasSameParent() const;
LayerList toLayerList() const;
LayerList toAllLayersList() const;
void removeChildrenIfParentIsSelected();
void expandCollapsedGroups();

View File

@ -215,6 +215,14 @@ LayerImage* Sprite::backgroundLayer() const
return NULL;
}
Layer* Sprite::firstLayer() const
{
Layer* layer = root()->firstLayer();
while (layer->isGroup())
layer = static_cast<LayerGroup*>(layer)->firstLayer();
return layer;
}
Layer* Sprite::firstBrowsableLayer() const
{
Layer* layer = root()->firstLayer();

View File

@ -104,6 +104,7 @@ namespace doc {
LayerGroup* root() const { return m_root; }
LayerImage* backgroundLayer() const;
Layer* firstBrowsableLayer() const;
Layer* firstLayer() const;
layer_t allLayersCount() const;
bool hasVisibleReferenceLayers() const;