Mercurial > hg > svcore
changeset 1389:770f80d9ccee
Invalidate an aggregate model when one of its components announces it's about to be deleted
author | Chris Cannam |
---|---|
date | Mon, 27 Feb 2017 15:43:30 +0000 |
parents | 246876022b35 |
children | 1a572937ed8c |
files | data/model/AggregateWaveModel.cpp data/model/AggregateWaveModel.h |
diffstat | 2 files changed, 26 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/data/model/AggregateWaveModel.cpp Mon Feb 27 15:06:17 2017 +0000 +++ b/data/model/AggregateWaveModel.cpp Mon Feb 27 15:43:30 2017 +0000 @@ -25,10 +25,15 @@ AggregateWaveModel::m_zoomConstraint; AggregateWaveModel::AggregateWaveModel(ChannelSpecList channelSpecs) : - m_components(channelSpecs) + m_components(channelSpecs), + m_invalidated(false) { for (ChannelSpecList::const_iterator i = channelSpecs.begin(); i != channelSpecs.end(); ++i) { + + connect(i->model, SIGNAL(aboutToBeDeleted()), + this, SLOT(componentModelAboutToBeDeleted())); + if (i->model->getSampleRate() != channelSpecs.begin()->model->getSampleRate()) { SVDEBUG << "AggregateWaveModel::AggregateWaveModel: WARNING: Component models do not all have the same sample rate" << endl; @@ -41,12 +46,26 @@ { } +void +AggregateWaveModel::componentModelAboutToBeDeleted() +{ + SVDEBUG << "AggregateWaveModel::componentModelAboutToBeDeleted: invalidating" + << endl; + m_components.clear(); + m_invalidated = true; +} + bool AggregateWaveModel::isOK() const { + if (m_invalidated) { + return false; + } for (ChannelSpecList::const_iterator i = m_components.begin(); i != m_components.end(); ++i) { - if (!i->model->isOK()) return false; + if (!i->model->isOK()) { + return false; + } } return true; } @@ -55,6 +74,7 @@ AggregateWaveModel::isReady(int *completion) const { if (completion) *completion = 100; + bool ready = true; for (ChannelSpecList::const_iterator i = m_components.begin(); i != m_components.end(); ++i) { @@ -71,13 +91,12 @@ AggregateWaveModel::getFrameCount() const { sv_frame_t count = 0; - for (ChannelSpecList::const_iterator i = m_components.begin(); i != m_components.end(); ++i) { - sv_frame_t thisCount = i->model->getEndFrame() - i->model->getStartFrame(); + sv_frame_t thisCount = + i->model->getEndFrame() - i->model->getStartFrame(); if (thisCount > count) count = thisCount; } - return count; }
--- a/data/model/AggregateWaveModel.h Mon Feb 27 15:06:17 2017 +0000 +++ b/data/model/AggregateWaveModel.h Mon Feb 27 15:43:30 2017 +0000 @@ -84,10 +84,12 @@ void componentModelChanged(); void componentModelChangedWithin(sv_frame_t, sv_frame_t); void componentModelCompletionChanged(); + void componentModelAboutToBeDeleted(); protected: ChannelSpecList m_components; static PowerOfSqrtTwoZoomConstraint m_zoomConstraint; + bool m_invalidated; // because one of its component models is aboutToBeDeleted }; #endif