# HG changeset patch # User Chris Cannam # Date 1560454570 -3600 # Node ID 1f18e0f64af8f7aa7958356a3b9166aea8492ee4 # Parent 16c1077da62c76dc8cd014c1e0f2c9062c5f2cc3 Defer alignment for recorded audio until recording is complete diff -r 16c1077da62c -r 1f18e0f64af8 framework/Document.cpp --- a/framework/Document.cpp Thu Jun 13 11:32:59 2019 +0100 +++ b/framework/Document.cpp Thu Jun 13 20:36:10 2019 +0100 @@ -43,7 +43,7 @@ using std::vector; -//#define DEBUG_DOCUMENT 1 +#define DEBUG_DOCUMENT 1 //!!! still need to handle command history, documentRestored/documentModified @@ -1121,7 +1121,7 @@ { SVDEBUG << "Document::alignModel(" << model << ", " << forceRecalculate << ") (main model is " << m_mainModel << ")" << endl; - + RangeSummarisableTimeValueModel *rm = dynamic_cast(model); if (!rm) { @@ -1161,6 +1161,17 @@ return; } + WritableWaveFileModel *w = + dynamic_cast(model); + if (w && w->getWriteProportion() < 100) { + SVDEBUG << "Document::alignModel(" << model + << "): model write is not complete, deferring" + << endl; + connect(w, SIGNAL(writeCompleted()), + this, SLOT(performDeferredAlignment())); + return; + } + SVDEBUG << "Document::alignModel: aligning..." << endl; if (rm->getAlignmentReference() != nullptr) { SVDEBUG << "(Note: model " << rm << " is currently aligned to model " @@ -1176,6 +1187,19 @@ } void +Document::performDeferredAlignment() +{ + QObject *s = sender(); + Model *m = dynamic_cast(s); + if (!m) { + SVDEBUG << "Document::performDeferredAlignment: sender is not a Model" << endl; + } else { + SVDEBUG << "Document::performDeferredAlignment: aligning..." << endl; + alignModel(m); + } +} + +void Document::alignModels() { for (const ModelRecord &rec: m_models) { diff -r 16c1077da62c -r 1f18e0f64af8 framework/Document.h --- a/framework/Document.h Thu Jun 13 11:32:59 2019 +0100 +++ b/framework/Document.h Thu Jun 13 20:36:10 2019 +0100 @@ -338,6 +338,7 @@ protected slots: void aggregateModelInvalidated(); + void performDeferredAlignment(); protected: void releaseModel(Model *model);