# HG changeset patch # User Chris Cannam # Date 1554372943 -3600 # Node ID e73baeead27f69dcfc6c99c50d5f5b12d53de4f4 # Parent 0e9840a381b5cb21707374f3c4d853171a2bfbfb Model deletion issues - the AlignmentModel doesn't actually need to know about the input aggregate model; the document should own it instead diff -r 0e9840a381b5 -r e73baeead27f data/model/AggregateWaveModel.cpp --- a/data/model/AggregateWaveModel.cpp Wed Apr 03 16:19:20 2019 +0100 +++ b/data/model/AggregateWaveModel.cpp Thu Apr 04 11:15:43 2019 +0100 @@ -46,6 +46,7 @@ AggregateWaveModel::~AggregateWaveModel() { + SVDEBUG << "AggregateWaveModel::~AggregateWaveModel" << endl; } void @@ -61,7 +62,7 @@ bool AggregateWaveModel::isOK() const { - if (m_invalidated) { + if (m_invalidated || m_components.empty()) { return false; } for (ChannelSpecList::const_iterator i = m_components.begin(); @@ -120,13 +121,15 @@ sv_samplerate_t AggregateWaveModel::getSampleRate() const { - if (m_components.empty()) return 0; + if (m_invalidated || m_components.empty()) return 0; return m_components.begin()->model->getSampleRate(); } floatvec_t AggregateWaveModel::getData(int channel, sv_frame_t start, sv_frame_t count) const { + if (m_invalidated || m_components.empty()) return {}; + int ch0 = channel, ch1 = channel; if (channel == -1) { ch0 = 0; diff -r 0e9840a381b5 -r e73baeead27f data/model/AlignmentModel.cpp --- a/data/model/AlignmentModel.cpp Wed Apr 03 16:19:20 2019 +0100 +++ b/data/model/AlignmentModel.cpp Thu Apr 04 11:15:43 2019 +0100 @@ -21,11 +21,9 @@ AlignmentModel::AlignmentModel(Model *reference, Model *aligned, - Model *inputModel, SparseTimeValueModel *path) : m_reference(reference), m_aligned(aligned), - m_inputModel(inputModel), m_rawPath(path), m_path(nullptr), m_reversePath(nullptr), @@ -55,9 +53,6 @@ AlignmentModel::~AlignmentModel() { SVDEBUG << "AlignmentModel(" << this << ")::~AlignmentModel()" << endl; - - if (m_inputModel) m_inputModel->aboutToDelete(); - delete m_inputModel; if (m_rawPath) m_rawPath->aboutToDelete(); delete m_rawPath; @@ -214,10 +209,7 @@ constructPath(); constructReversePath(); - SVDEBUG << "AlignmentModel: path complete, deleting input" << endl; - if (m_inputModel) m_inputModel->aboutToDelete(); - delete m_inputModel; - m_inputModel = nullptr; + SVDEBUG << "AlignmentModel: path complete" << endl; } } diff -r 0e9840a381b5 -r e73baeead27f data/model/AlignmentModel.h --- a/data/model/AlignmentModel.h Wed Apr 03 16:19:20 2019 +0100 +++ b/data/model/AlignmentModel.h Thu Apr 04 11:15:43 2019 +0100 @@ -32,8 +32,7 @@ public: AlignmentModel(Model *reference, Model *aligned, - Model *inputModel, // probably an AggregateWaveModel; may be null; I take ownership - SparseTimeValueModel *path); // I take ownership + SparseTimeValueModel *path); ~AlignmentModel(); bool isOK() const override; @@ -82,8 +81,6 @@ Model *m_reference; // I don't own this Model *m_aligned; // I don't own this - Model *m_inputModel; // I own this - SparseTimeValueModel *m_rawPath; // I own this mutable PathModel *m_path; // I own this mutable PathModel *m_reversePath; // I own this diff -r 0e9840a381b5 -r e73baeead27f data/model/FFTModel.cpp --- a/data/model/FFTModel.cpp Wed Apr 03 16:19:20 2019 +0100 +++ b/data/model/FFTModel.cpp Thu Apr 04 11:15:43 2019 +0100 @@ -61,9 +61,12 @@ m_fft.initFloat(); - connect(model, SIGNAL(modelChanged()), this, SIGNAL(modelChanged())); + connect(model, SIGNAL(modelChanged()), + this, SIGNAL(modelChanged())); connect(model, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)), this, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t))); + connect(model, SIGNAL(aboutToBeDeleted()), + this, SLOT(sourceModelAboutToBeDeleted())); } FFTModel::~FFTModel() @@ -273,6 +276,8 @@ FFTModel::getSourceDataUncached(pair range) const { Profiler profiler("FFTModel::getSourceDataUncached"); + + if (!m_model) return {}; decltype(range.first) pfx = 0; if (range.first < 0) {