Mercurial > hg > svapp
diff align/TransformAligner.cpp @ 761:6429a164b7e1 pitch-align
Schedule alignments with a small delay to avoid too much UI unresponsiveness. Also overhaul error reporting to use signals throughout.
author | Chris Cannam |
---|---|
date | Wed, 06 May 2020 11:45:27 +0100 |
parents | 31289e8592c7 |
children | dd742e566e60 |
line wrap: on
line diff
--- a/align/TransformAligner.cpp Mon Apr 27 14:59:56 2020 +0100 +++ b/align/TransformAligner.cpp Wed May 06 11:45:27 2020 +0100 @@ -93,15 +93,15 @@ (tdId == "" || factory->haveTransform(tdId)); } -bool -TransformAligner::begin(QString &error) +void +TransformAligner::begin() { auto reference = ModelById::getAs<RangeSummarisableTimeValueModel>(m_reference); auto other = ModelById::getAs<RangeSummarisableTimeValueModel>(m_toAlign); - if (!reference || !other) return false; + if (!reference || !other) return; // This involves creating a number of new models: // @@ -165,9 +165,10 @@ other->setAlignment(m_alignmentModel); m_document->addNonDerivedModel(m_alignmentModel); } else { - error = alignmentModel->getError(); + QString error = alignmentModel->getError(); ModelById::release(alignmentModel); - return false; + emit failed(m_toAlign, error); + return; } } else { @@ -197,9 +198,9 @@ ModelById::getAs<SparseTimeValueModel>(m_tuningDiffOutputModel); if (!tuningDiffOutputModel) { SVCERR << "Align::alignModel: ERROR: Failed to create tuning-difference output model (no Tuning Difference plugin?)" << endl; - error = message; ModelById::release(alignmentModel); - return false; + emit failed(m_toAlign, message); + return; } other->setAlignment(m_alignmentModel); @@ -218,13 +219,16 @@ progressModel->setCompletion(0); alignmentModel->setPathFrom(m_tuningDiffProgressModel); } - - return true; } void TransformAligner::tuningDifferenceCompletionChanged(ModelId tuningDiffOutputModelId) { + if (m_tuningDiffOutputModel.isNone()) { + // we're done, this is probably a spurious queued event + return; + } + if (tuningDiffOutputModelId != m_tuningDiffOutputModel) { SVCERR << "WARNING: TransformAligner::tuningDifferenceCompletionChanged: Model " << tuningDiffOutputModelId @@ -252,6 +256,10 @@ int completion = 0; bool done = tuningDiffOutputModel->isReady(&completion); + SVDEBUG << "TransformAligner::tuningDifferenceCompletionChanged: model " + << m_tuningDiffOutputModel << ", completion = " << completion + << ", done = " << done << endl; + if (!done) { // This will be the completion the alignment model reports, // before the alignment actually begins. It goes up from 0 to