changeset 677:4d26b66931f8

Abandon aggregate models on deletion (e.g. when document is replaced during processing)
author Chris Cannam
date Tue, 11 Jun 2019 13:39:50 +0100
parents 0d4236961c97
children 16c1077da62c
files framework/Align.cpp framework/Align.h
diffstat 2 files changed, 26 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/framework/Align.cpp	Tue Jun 11 13:39:17 2019 +0100
+++ b/framework/Align.cpp	Tue Jun 11 13:39:50 2019 +0100
@@ -201,6 +201,9 @@
         rec.input = aggregateModel;
         rec.alignment = alignmentModel;
 
+        connect(aggregateModel, SIGNAL(aboutToBeDeleted()),
+                this, SLOT(aggregateModelAboutToBeDeleted()));
+        
         // This model exists only so that the AlignmentModel can get a
         // completion value from somewhere while the tuning difference
         // calculation is going on
@@ -216,6 +219,28 @@
 }
 
 void
+Align::aggregateModelAboutToBeDeleted()
+{
+    SVCERR << "Align::aggregateModelAboutToBeDeleted" << endl;
+
+    QObject *s = sender();
+    AggregateWaveModel *awm = qobject_cast<AggregateWaveModel *>(s);
+    if (!awm) return;
+    QMutexLocker locker(&m_mutex);
+
+    SVCERR << "Align::aggregateModelAboutToBeDeleted: awm = " << awm
+           << endl;
+
+    for (const auto &p : m_pendingTuningDiffs) {
+        if (p.second.input == awm) {
+            SVCERR << "we have a record of this, getting rid of it" << endl;
+            m_pendingTuningDiffs.erase(p.first);
+            return;
+        }
+    }
+}
+
+void
 Align::tuningDifferenceCompletionChanged()
 {
     QMutexLocker locker (&m_mutex);
--- a/framework/Align.h	Tue Jun 11 13:39:17 2019 +0100
+++ b/framework/Align.h	Tue Jun 11 13:39:50 2019 +0100
@@ -96,6 +96,7 @@
     void alignmentCompletionChanged();
     void tuningDifferenceCompletionChanged();
     void alignmentProgramFinished(int, QProcess::ExitStatus);
+    void aggregateModelAboutToBeDeleted();
     
 private:
     static QString getAlignmentTransformName();