# HG changeset patch # User Chris Cannam # Date 1556300386 -3600 # Node ID 31ea416fea3c4d3d7f7682ca39a07cbc05ae8bdd # Parent 21673429dba5b2036a83c26a096505903d3346b4 Ensure main model also gets aligned (as reference) diff -r 21673429dba5 -r 31ea416fea3c framework/Document.cpp --- a/framework/Document.cpp Wed Apr 24 11:45:31 2019 +0100 +++ b/framework/Document.cpp Fri Apr 26 18:39:46 2019 +0100 @@ -579,6 +579,8 @@ if (m_autoAlignment) { SVDEBUG << "Document::setMainModel: auto-alignment is on, aligning model if possible" << endl; alignModel(m_mainModel); + } else { + SVDEBUG << "Document::setMainModel: auto-alignment is off" << endl; } emit mainModelChanged(m_mainModel); @@ -1101,7 +1103,7 @@ void Document::alignModel(Model *model) { - SVDEBUG << "Document::alignModel(" << model << ")" << endl; + SVDEBUG << "Document::alignModel(" << model << ") (main model is " << m_mainModel << ")" << endl; if (!m_mainModel) { SVDEBUG << "(no main model to align to)" << endl; @@ -1111,7 +1113,7 @@ RangeSummarisableTimeValueModel *rm = dynamic_cast(model); if (!rm) { - SVDEBUG << "(main model is not alignable-to)" << endl; + SVDEBUG << "(model " << rm << " is not an alignable sort)" << endl; return; } @@ -1125,11 +1127,18 @@ // it possible to distinguish between the reference and any // unaligned model just by looking at the model itself, // without also knowing what the main model is - SVDEBUG << "Document::alignModel(" << model << "): is main model, setting appropriately" << endl; + SVDEBUG << "Document::alignModel(" << model << "): is main model, setting alignment to itself appropriately" << endl; rm->setAlignment(new AlignmentModel(model, model, nullptr)); return; } + SVDEBUG << "Document::alignModel: aligning..." << endl; + if (rm->getAlignmentReference() != nullptr) { + SVDEBUG << "(Note: model " << rm << " is currently aligned to model " + << rm->getAlignmentReference() << "; this will replace that)" + << endl; + } + if (!m_align->alignModel(this, m_mainModel, rm)) { SVCERR << "Alignment failed: " << m_align->getError() << endl; emit alignmentFailed(m_align->getError()); diff -r 21673429dba5 -r 31ea416fea3c framework/MainWindowBase.cpp --- a/framework/MainWindowBase.cpp Wed Apr 24 11:45:31 2019 +0100 +++ b/framework/MainWindowBase.cpp Fri Apr 26 18:39:46 2019 +0100 @@ -2680,6 +2680,8 @@ connect(m_document, SIGNAL(alignmentFailed(QString)), this, SLOT(alignmentFailed(QString))); + m_document->setAutoAlignment(m_viewManager->getAlignMode()); + emit replacedDocument(); }