Mercurial > hg > svapp
comparison framework/SVFileReader.cpp @ 662:ffd213b292f9 single-point
Avoid arbitrarily reordering models from file order on load
author | Chris Cannam |
---|---|
date | Tue, 02 Apr 2019 14:32:57 +0100 |
parents | 365c61ac7680 |
children | 06db8f3ceb95 |
comparison
equal
deleted
inserted
replaced
661:a2bf5e6c54ce | 662:ffd213b292f9 |
---|---|
456 void | 456 void |
457 SVFileReader::addUnaddedModels() | 457 SVFileReader::addUnaddedModels() |
458 { | 458 { |
459 makeAggregateModels(); | 459 makeAggregateModels(); |
460 | 460 |
461 std::set<Model *> unaddedModels; | |
462 | |
463 for (std::map<int, Model *>::iterator i = m_models.begin(); | 461 for (std::map<int, Model *>::iterator i = m_models.begin(); |
464 i != m_models.end(); ++i) { | 462 i != m_models.end(); ++i) { |
465 if (m_addedModels.find(i->second) == m_addedModels.end()) { | 463 |
466 unaddedModels.insert(i->second); | 464 Model *model = i->second; |
467 } | 465 |
468 } | 466 if (m_addedModels.find(model) != m_addedModels.end()) { |
469 | 467 // already added this one |
470 for (std::set<Model *>::iterator i = unaddedModels.begin(); | 468 continue; |
471 i != unaddedModels.end(); ++i) { | 469 } |
472 Model *model = *i; | 470 |
473 // don't want to add these models, because their lifespans | 471 // don't want to add path and alignment models to the |
474 // are entirely dictated by the models that "own" them even | 472 // document, because their lifespans are entirely dictated by |
475 // though they were read independently from the .sv file. | 473 // the models that "own" them even though they were read |
476 // (pity we don't have a nicer way) | 474 // independently from the .sv file. (pity we don't have a |
475 // nicer way to handle this) | |
477 if (!dynamic_cast<PathModel *>(model) && | 476 if (!dynamic_cast<PathModel *>(model) && |
478 !dynamic_cast<AlignmentModel *>(model)) { | 477 !dynamic_cast<AlignmentModel *>(model)) { |
478 | |
479 m_document->addImportedModel(model); | 479 m_document->addImportedModel(model); |
480 } | 480 } |
481 // but we add all models here, so they don't get deleted | 481 |
482 // when the file loader is destroyed | 482 // but we add all models including path and alignment ones to |
483 // the added set, so they don't get deleted from our own | |
484 // destructor | |
483 m_addedModels.insert(model); | 485 m_addedModels.insert(model); |
484 } | 486 } |
485 } | 487 } |
486 | 488 |
487 bool | 489 bool |