# HG changeset patch # User Chris Cannam # Date 1554211977 -3600 # Node ID ffd213b292f906184a4c22d3366278b1b4b6cbf3 # Parent a2bf5e6c54ceea8a9dbe9d8a4d6e8633da2ad0bd Avoid arbitrarily reordering models from file order on load diff -r a2bf5e6c54ce -r ffd213b292f9 framework/SVFileReader.cpp --- a/framework/SVFileReader.cpp Tue Apr 02 14:32:24 2019 +0100 +++ b/framework/SVFileReader.cpp Tue Apr 02 14:32:57 2019 +0100 @@ -458,28 +458,30 @@ { makeAggregateModels(); - std::set unaddedModels; - for (std::map::iterator i = m_models.begin(); i != m_models.end(); ++i) { - if (m_addedModels.find(i->second) == m_addedModels.end()) { - unaddedModels.insert(i->second); + + Model *model = i->second; + + if (m_addedModels.find(model) != m_addedModels.end()) { + // already added this one + continue; } - } - - for (std::set::iterator i = unaddedModels.begin(); - i != unaddedModels.end(); ++i) { - Model *model = *i; - // don't want to add these models, because their lifespans - // are entirely dictated by the models that "own" them even - // though they were read independently from the .sv file. - // (pity we don't have a nicer way) + + // don't want to add path and alignment models to the + // document, because their lifespans are entirely dictated by + // the models that "own" them even though they were read + // independently from the .sv file. (pity we don't have a + // nicer way to handle this) if (!dynamic_cast(model) && !dynamic_cast(model)) { + m_document->addImportedModel(model); } - // but we add all models here, so they don't get deleted - // when the file loader is destroyed + + // but we add all models including path and alignment ones to + // the added set, so they don't get deleted from our own + // destructor m_addedModels.insert(model); } }