Mercurial > hg > svapp
changeset 663:351b1302064e single-point
Make layer order in document also stable on file load/save
author | Chris Cannam |
---|---|
date | Tue, 02 Apr 2019 14:45:57 +0100 |
parents | ffd213b292f9 |
children | 06db8f3ceb95 |
files | framework/Document.cpp framework/Document.h |
diffstat | 2 files changed, 16 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/framework/Document.cpp Tue Apr 02 14:32:57 2019 +0100 +++ b/framework/Document.cpp Tue Apr 02 14:45:57 2019 +0100 @@ -126,7 +126,7 @@ newLayer->setObjectName(getUniqueLayerName(newLayer->objectName())); - m_layers.insert(newLayer); + m_layers.push_back(newLayer); #ifdef DEBUG_DOCUMENT SVDEBUG << "Document::createLayer: Added layer of type " << type @@ -172,7 +172,7 @@ //!!! and all channels setChannel(newLayer, -1); - m_layers.insert(newLayer); + m_layers.push_back(newLayer); #ifdef DEBUG_DOCUMENT SVDEBUG << "Document::createImportedLayer: Added layer of type " << type @@ -439,9 +439,8 @@ SVDEBUG << "Old main model: " << oldMainModel << endl; #endif - for (LayerSet::iterator i = m_layers.begin(); i != m_layers.end(); ++i) { + for (Layer *layer: m_layers) { - Layer *layer = *i; Model *model = layer->getModel(); #ifdef DEBUG_DOCUMENT @@ -880,7 +879,15 @@ } } - if (m_layers.find(layer) == m_layers.end()) { + bool found = false; + for (auto itr = m_layers.begin(); itr != m_layers.end(); ++itr) { + if (*itr == layer) { + found = true; + m_layers.erase(itr); + break; + } + } + if (!found) { SVDEBUG << "Document::deleteLayer: Layer " << layer << " (" << typeid(layer).name() << ") does not exist, or has already been deleted " @@ -888,8 +895,6 @@ return; } - m_layers.erase(layer); - #ifdef DEBUG_DOCUMENT SVDEBUG << "Document::deleteLayer: Removing, now have " << m_layers.size() << " layers" << endl; @@ -1030,7 +1035,7 @@ bool duplicate = false; - for (LayerSet::iterator i = m_layers.begin(); i != m_layers.end(); ++i) { + for (auto i = m_layers.begin(); i != m_layers.end(); ++i) { if ((*i)->objectName() == adjusted) { duplicate = true; break; @@ -1459,9 +1464,7 @@ alignment->toXml(out, indent + " "); } - for (LayerSet::const_iterator i = m_layers.begin(); - i != m_layers.end(); ++i) { - + for (auto i = m_layers.begin(); i != m_layers.end(); ++i) { (*i)->toXml(out, indent + " "); }
--- a/framework/Document.h Tue Apr 02 14:32:57 2019 +0100 +++ b/framework/Document.h Tue Apr 02 14:45:57 2019 +0100 @@ -481,8 +481,8 @@ * And these are the layers. We also control the lifespans of * these (usually through the commands used to add and remove them). */ - typedef std::set<Layer *> LayerSet; - LayerSet m_layers; + typedef std::vector<Layer *> LayerList; + LayerList m_layers; bool m_autoAlignment; Align *m_align;