Mercurial > hg > svapp
comparison framework/Document.cpp @ 664:06db8f3ceb95 single-point
Update so Document owns the alignment model's input aggregate model, just as any other model
author | Chris Cannam |
---|---|
date | Thu, 04 Apr 2019 11:16:29 +0100 |
parents | 351b1302064e |
children | 21673429dba5 |
comparison
equal
deleted
inserted
replaced
663:351b1302064e | 664:06db8f3ceb95 |
---|---|
432 SVDEBUG << "Document::setMainModel: Have " | 432 SVDEBUG << "Document::setMainModel: Have " |
433 << m_layers.size() << " layers" << endl; | 433 << m_layers.size() << " layers" << endl; |
434 SVDEBUG << "Models now: "; | 434 SVDEBUG << "Models now: "; |
435 for (const auto &r: m_models) { | 435 for (const auto &r: m_models) { |
436 SVDEBUG << r.model << " "; | 436 SVDEBUG << r.model << " "; |
437 } | 437 } |
438 SVDEBUG << endl; | 438 SVDEBUG << endl; |
439 SVDEBUG << "Old main model: " << oldMainModel << endl; | 439 SVDEBUG << "Old main model: " << oldMainModel << endl; |
440 #endif | 440 #endif |
441 | 441 |
442 for (Layer *layer: m_layers) { | 442 for (Layer *layer: m_layers) { |
789 { | 789 { |
790 if (model == nullptr) { | 790 if (model == nullptr) { |
791 return; | 791 return; |
792 } | 792 } |
793 | 793 |
794 #ifdef DEBUG_DOCUMENT | |
795 SVDEBUG << "Document::releaseModel(" << model << ", type " | |
796 << model->getTypeName() << ", name \"" | |
797 << model->objectName() << "\")" << endl; | |
798 #endif | |
799 | |
794 if (model == m_mainModel) { | 800 if (model == m_mainModel) { |
795 return; | 801 return; |
796 } | 802 } |
797 | 803 |
798 bool toDelete = false; | 804 bool toDelete = false; |
802 if (mitr != m_models.end()) { | 808 if (mitr != m_models.end()) { |
803 if (mitr->refcount == 0) { | 809 if (mitr->refcount == 0) { |
804 SVCERR << "WARNING: Document::releaseModel: model " << model | 810 SVCERR << "WARNING: Document::releaseModel: model " << model |
805 << " reference count is zero already!" << endl; | 811 << " reference count is zero already!" << endl; |
806 } else { | 812 } else { |
813 #ifdef DEBUG_DOCUMENT | |
814 SVDEBUG << "Lowering refcount from " << mitr->refcount << endl; | |
815 #endif | |
807 if (--mitr->refcount == 0) { | 816 if (--mitr->refcount == 0) { |
808 toDelete = true; | 817 toDelete = true; |
809 } | 818 } |
810 } | 819 } |
811 } else if (m_aggregateModels.find(model) != m_aggregateModels.end()) { | 820 } else if (m_aggregateModels.find(model) != m_aggregateModels.end()) { |
821 #ifdef DEBUG_DOCUMENT | |
812 SVDEBUG << "Document::releaseModel: is an aggregate model" << endl; | 822 SVDEBUG << "Document::releaseModel: is an aggregate model" << endl; |
823 #endif | |
813 toDelete = true; | 824 toDelete = true; |
814 } else { | 825 } else { |
815 SVCERR << "WARNING: Document::releaseModel: Unfound model " | 826 SVCERR << "WARNING: Document::releaseModel: Unfound model " |
816 << model << endl; | 827 << model << endl; |
817 toDelete = true; | 828 toDelete = true; |
887 break; | 898 break; |
888 } | 899 } |
889 } | 900 } |
890 if (!found) { | 901 if (!found) { |
891 SVDEBUG << "Document::deleteLayer: Layer " | 902 SVDEBUG << "Document::deleteLayer: Layer " |
892 << layer << " (" << typeid(layer).name() << | 903 << layer << " (typeid " << typeid(layer).name() << |
893 ") does not exist, or has already been deleted " | 904 ") does not exist, or has already been deleted " |
894 << "(this may not be as serious as it sounds)" << endl; | 905 << "(this may not be as serious as it sounds)" << endl; |
895 return; | 906 return; |
896 } | 907 } |
897 | 908 |
898 #ifdef DEBUG_DOCUMENT | 909 #ifdef DEBUG_DOCUMENT |
899 SVDEBUG << "Document::deleteLayer: Removing, now have " | 910 SVDEBUG << "Document::deleteLayer: Removing (and about to release model), now have " |
900 << m_layers.size() << " layers" << endl; | 911 << m_layers.size() << " layers" << endl; |
901 #endif | 912 #endif |
902 | 913 |
903 releaseModel(layer->getModel()); | 914 releaseModel(layer->getModel()); |
904 emit layerRemoved(layer); | 915 emit layerRemoved(layer); |
1113 // The reference has an empty alignment to itself. This makes | 1124 // The reference has an empty alignment to itself. This makes |
1114 // it possible to distinguish between the reference and any | 1125 // it possible to distinguish between the reference and any |
1115 // unaligned model just by looking at the model itself, | 1126 // unaligned model just by looking at the model itself, |
1116 // without also knowing what the main model is | 1127 // without also knowing what the main model is |
1117 SVDEBUG << "Document::alignModel(" << model << "): is main model, setting appropriately" << endl; | 1128 SVDEBUG << "Document::alignModel(" << model << "): is main model, setting appropriately" << endl; |
1118 rm->setAlignment(new AlignmentModel(model, model, nullptr, nullptr)); | 1129 rm->setAlignment(new AlignmentModel(model, model, nullptr)); |
1119 return; | 1130 return; |
1120 } | 1131 } |
1121 | 1132 |
1122 if (!m_align->alignModel(m_mainModel, rm)) { | 1133 if (!m_align->alignModel(this, m_mainModel, rm)) { |
1123 SVCERR << "Alignment failed: " << m_align->getError() << endl; | 1134 SVCERR << "Alignment failed: " << m_align->getError() << endl; |
1124 emit alignmentFailed(m_align->getError()); | 1135 emit alignmentFailed(m_align->getError()); |
1125 } | 1136 } |
1126 } | 1137 } |
1127 | 1138 |