Mercurial > hg > sonic-visualiser
comparison document/SVFileReader.cpp @ 173:102317ae3970
* Better abbreviation modes for layer names in pane (and input model combo
of plugin parameter dialog)
* Avoid crash when loading SV file containing model derived from nonexistent
model (shouldn't happen of course, but see bug #1771769)
* Remember last-used input model in plugin parameter dialog
* Don't override a layer colour loaded from a session file with the generated
default colour when attaching it to a view
author | Chris Cannam |
---|---|
date | Fri, 10 Aug 2007 16:36:50 +0000 |
parents | 567df8af372c |
children | aaf806ce329a |
comparison
equal
deleted
inserted
replaced
172:c1980ed39d2e | 173:102317ae3970 |
---|---|
251 | 251 |
252 bool foundInAwaiting = false; | 252 bool foundInAwaiting = false; |
253 | 253 |
254 for (std::map<int, int>::iterator i = m_awaitingDatasets.begin(); | 254 for (std::map<int, int>::iterator i = m_awaitingDatasets.begin(); |
255 i != m_awaitingDatasets.end(); ++i) { | 255 i != m_awaitingDatasets.end(); ++i) { |
256 if (m_models[i->second] == m_currentDataset) { | 256 if (haveModel(i->second) && |
257 m_models[i->second] == m_currentDataset) { | |
257 m_awaitingDatasets.erase(i); | 258 m_awaitingDatasets.erase(i); |
258 foundInAwaiting = true; | 259 foundInAwaiting = true; |
259 break; | 260 break; |
260 } | 261 } |
261 } | 262 } |
276 | 277 |
277 if (!m_currentDerivedModel) { | 278 if (!m_currentDerivedModel) { |
278 if (m_currentDerivedModel < 0) { | 279 if (m_currentDerivedModel < 0) { |
279 std::cerr << "WARNING: SV-XML: Bad derivation output model id " | 280 std::cerr << "WARNING: SV-XML: Bad derivation output model id " |
280 << m_currentDerivedModelId << std::endl; | 281 << m_currentDerivedModelId << std::endl; |
281 } else if (m_models[m_currentDerivedModelId]) { | 282 } else if (haveModel(m_currentDerivedModelId)) { |
282 std::cerr << "WARNING: SV-XML: Derivation has existing model " | 283 std::cerr << "WARNING: SV-XML: Derivation has existing model " |
283 << m_currentDerivedModelId | 284 << m_currentDerivedModelId |
284 << " as target, not regenerating" << std::endl; | 285 << " as target, not regenerating" << std::endl; |
285 } else { | 286 } else { |
286 m_currentDerivedModel = m_models[m_currentDerivedModelId] = | 287 m_currentDerivedModel = m_models[m_currentDerivedModelId] = |
386 { | 387 { |
387 bool ok = false; | 388 bool ok = false; |
388 | 389 |
389 READ_MANDATORY(int, id, toInt); | 390 READ_MANDATORY(int, id, toInt); |
390 | 391 |
391 if (m_models.find(id) != m_models.end()) { | 392 if (haveModel(id)) { |
392 std::cerr << "WARNING: SV-XML: Ignoring duplicate model id " << id | 393 std::cerr << "WARNING: SV-XML: Ignoring duplicate model id " << id |
393 << std::endl; | 394 << std::endl; |
394 return false; | 395 return false; |
395 } | 396 } |
396 | 397 |
710 int modelId; | 711 int modelId; |
711 bool modelOk = false; | 712 bool modelOk = false; |
712 modelId = attributes.value("model").trimmed().toInt(&modelOk); | 713 modelId = attributes.value("model").trimmed().toInt(&modelOk); |
713 | 714 |
714 if (modelOk) { | 715 if (modelOk) { |
715 if (m_models.find(modelId) != m_models.end()) { | 716 if (haveModel(modelId)) { |
716 Model *model = m_models[modelId]; | 717 Model *model = m_models[modelId]; |
717 m_document->setModel(layer, model); | 718 m_document->setModel(layer, model); |
718 } else { | 719 } else { |
719 std::cerr << "WARNING: SV-XML: Unknown model id " << modelId | 720 std::cerr << "WARNING: SV-XML: Unknown model id " << modelId |
720 << " in layer definition" << std::endl; | 721 << " in layer definition" << std::endl; |
763 } | 764 } |
764 | 765 |
765 int modelId = m_awaitingDatasets[id]; | 766 int modelId = m_awaitingDatasets[id]; |
766 | 767 |
767 Model *model = 0; | 768 Model *model = 0; |
768 if (m_models.find(modelId) != m_models.end()) { | 769 if (haveModel(modelId)) { |
769 model = m_models[modelId]; | 770 model = m_models[modelId]; |
770 } else { | 771 } else { |
771 std::cerr << "WARNING: SV-XML: Internal error: Unknown model " << modelId | 772 std::cerr << "WARNING: SV-XML: Internal error: Unknown model " << modelId |
772 << " expecting dataset " << id << std::endl; | 773 << " expecting dataset " << id << std::endl; |
773 return false; | 774 return false; |
963 return false; | 964 return false; |
964 } | 965 } |
965 | 966 |
966 QString transform = attributes.value("transform"); | 967 QString transform = attributes.value("transform"); |
967 | 968 |
968 if (m_models.find(modelId) != m_models.end()) { | 969 if (haveModel(modelId)) { |
969 m_currentDerivedModel = m_models[modelId]; | 970 m_currentDerivedModel = m_models[modelId]; |
970 } else { | 971 } else { |
971 // we'll regenerate the model when the derivation element ends | 972 // we'll regenerate the model when the derivation element ends |
972 m_currentDerivedModel = 0; | 973 m_currentDerivedModel = 0; |
973 } | 974 } |
976 | 977 |
977 int sourceId = 0; | 978 int sourceId = 0; |
978 bool sourceOk = false; | 979 bool sourceOk = false; |
979 sourceId = attributes.value("source").trimmed().toInt(&sourceOk); | 980 sourceId = attributes.value("source").trimmed().toInt(&sourceOk); |
980 | 981 |
981 if (sourceOk && m_models[sourceId]) { | 982 if (sourceOk && haveModel(sourceId)) { |
982 m_currentTransformSource = m_models[sourceId]; | 983 m_currentTransformSource = m_models[sourceId]; |
983 } else { | 984 } else { |
984 m_currentTransformSource = m_document->getMainModel(); | 985 m_currentTransformSource = m_document->getMainModel(); |
985 } | 986 } |
986 | 987 |
1020 if (!modelOk) { | 1021 if (!modelOk) { |
1021 std::cerr << "WARNING: SV-XML: No model id specified for play parameters" << std::endl; | 1022 std::cerr << "WARNING: SV-XML: No model id specified for play parameters" << std::endl; |
1022 return false; | 1023 return false; |
1023 } | 1024 } |
1024 | 1025 |
1025 if (m_models.find(modelId) != m_models.end()) { | 1026 if (haveModel(modelId)) { |
1026 | 1027 |
1027 bool ok = false; | 1028 bool ok = false; |
1028 | 1029 |
1029 PlayParameters *parameters = PlayParameterRepository::getInstance()-> | 1030 PlayParameters *parameters = PlayParameterRepository::getInstance()-> |
1030 getPlayParameters(m_models[modelId]); | 1031 getPlayParameters(m_models[modelId]); |