Mercurial > hg > svapp
comparison framework/Document.cpp @ 687:e0b0f3e163ca by-id
Update for removal of (public) getId from Model
author | Chris Cannam |
---|---|
date | Fri, 05 Jul 2019 15:35:11 +0100 |
parents | 610fa108fbcc |
children | 827a522a5da4 |
comparison
equal
deleted
inserted
replaced
686:610fa108fbcc | 687:e0b0f3e163ca |
---|---|
84 } | 84 } |
85 for (auto m: m_aggregateModels) { | 85 for (auto m: m_aggregateModels) { |
86 ModelById::release(m); | 86 ModelById::release(m); |
87 } | 87 } |
88 | 88 |
89 auto mainModel = m_mainModel; | 89 if (!m_mainModel.isNone()) { |
90 ModelById::release(m_mainModel); | |
91 } | |
90 m_mainModel = {}; | 92 m_mainModel = {}; |
91 emit mainModelChanged(m_mainModel); | 93 emit mainModelChanged({}); |
92 ModelById::release(mainModel); | |
93 } | 94 } |
94 | 95 |
95 Layer * | 96 Layer * |
96 Document::createLayer(LayerFactory::LayerType type) | 97 Document::createLayer(LayerFactory::LayerType type) |
97 { | 98 { |
169 Layer *newLayer = createLayer(type); | 170 Layer *newLayer = createLayer(type); |
170 if (!newLayer) { | 171 if (!newLayer) { |
171 return nullptr; | 172 return nullptr; |
172 } | 173 } |
173 | 174 |
174 ModelById::add(newModel); | 175 auto newModelId = ModelById::add(newModel); |
175 addImportedModel(newModel->getId()); | 176 addImportedModel(newModelId); |
176 setModel(newLayer, newModel->getId()); | 177 setModel(newLayer, newModelId); |
177 | 178 |
178 return newLayer; | 179 return newLayer; |
179 } | 180 } |
180 | 181 |
181 Layer * | 182 Layer * |
552 SVDEBUG << "Document::setMainModel: auto-alignment is off" << endl; | 553 SVDEBUG << "Document::setMainModel: auto-alignment is off" << endl; |
553 } | 554 } |
554 | 555 |
555 emit mainModelChanged(m_mainModel); | 556 emit mainModelChanged(m_mainModel); |
556 | 557 |
557 // Remove the playable explicitly - the main model's dtor will do | 558 if (!oldMainModel.isNone()) { |
558 // this, but just in case something is still hanging onto a | 559 |
559 // shared_ptr to the old main model so it doesn't get deleted yet | 560 // Remove the playable explicitly - the main model's dtor will |
560 PlayParameterRepository::getInstance()->removePlayable | 561 // do this, but just in case something is still hanging onto a |
561 (oldMainModel.untyped); | 562 // shared_ptr to the old main model so it doesn't get deleted |
562 | 563 PlayParameterRepository::getInstance()->removePlayable |
563 ModelById::release(oldMainModel); | 564 (oldMainModel.untyped); |
565 | |
566 ModelById::release(oldMainModel); | |
567 } | |
564 } | 568 } |
565 | 569 |
566 void | 570 void |
567 Document::addAlreadyDerivedModel(const Transform &transform, | 571 Document::addAlreadyDerivedModel(const Transform &transform, |
568 const ModelTransformer::Input &input, | 572 const ModelTransformer::Input &input, |
1120 // without also knowing what the main model is | 1124 // without also knowing what the main model is |
1121 SVDEBUG << "Document::alignModel(" << modelId | 1125 SVDEBUG << "Document::alignModel(" << modelId |
1122 << "): is main model, setting alignment to itself" << endl; | 1126 << "): is main model, setting alignment to itself" << endl; |
1123 auto alignment = std::make_shared<AlignmentModel>(modelId, modelId, | 1127 auto alignment = std::make_shared<AlignmentModel>(modelId, modelId, |
1124 ModelId()); | 1128 ModelId()); |
1125 ModelById::add(alignment); | 1129 |
1126 //!!! hang on, who tracks alignment models? | 1130 //!!! hang on, who tracks alignment models? |
1127 rm->setAlignment(alignment->getId()); | 1131 rm->setAlignment(ModelById::add(alignment)); |
1128 return; | 1132 return; |
1129 } | 1133 } |
1130 | 1134 |
1131 auto w = ModelById::getAs<WritableWaveFileModel>(modelId); | 1135 auto w = ModelById::getAs<WritableWaveFileModel>(modelId); |
1132 if (w && w->getWriteProportion() < 100) { | 1136 if (w && w->getWriteProportion() < 100) { |
1133 SVDEBUG << "Document::alignModel(" << modelId | 1137 SVDEBUG << "Document::alignModel(" << modelId |
1134 << "): model write is not complete, deferring" | 1138 << "): model write is not complete, deferring" |
1135 << endl; | 1139 << endl; |
1136 connect(w.get(), SIGNAL(writeCompleted()), | 1140 connect(w.get(), SIGNAL(writeCompleted(ModelId)), |
1137 this, SLOT(performDeferredAlignment())); | 1141 this, SLOT(performDeferredAlignment(ModelId))); |
1138 return; | 1142 return; |
1139 } | 1143 } |
1140 | 1144 |
1141 SVDEBUG << "Document::alignModel: aligning..." << endl; | 1145 SVDEBUG << "Document::alignModel: aligning..." << endl; |
1142 if (!rm->getAlignmentReference().isNone()) { | 1146 if (!rm->getAlignmentReference().isNone()) { |
1151 emit alignmentFailed(err); | 1155 emit alignmentFailed(err); |
1152 } | 1156 } |
1153 } | 1157 } |
1154 | 1158 |
1155 void | 1159 void |
1156 Document::performDeferredAlignment() | 1160 Document::performDeferredAlignment(ModelId modelId) |
1157 { | 1161 { |
1158 ModelId modelId; | |
1159 if (Model *m = qobject_cast<Model *>(sender())) { | |
1160 modelId = m->getId(); | |
1161 } else { | |
1162 SVDEBUG << "Document::performDeferredAlignment: sender is not a Model" << endl; | |
1163 return; | |
1164 } | |
1165 | |
1166 SVDEBUG << "Document::performDeferredAlignment: aligning..." << endl; | 1162 SVDEBUG << "Document::performDeferredAlignment: aligning..." << endl; |
1167 alignModel(modelId); | 1163 alignModel(modelId); |
1168 } | 1164 } |
1169 | 1165 |
1170 void | 1166 void |