diff data/model/AggregateWaveModel.cpp @ 1686:e73baeead27f single-point

Model deletion issues - the AlignmentModel doesn't actually need to know about the input aggregate model; the document should own it instead
author Chris Cannam
date Thu, 04 Apr 2019 11:15:43 +0100
parents f97d64b8674f
children d08b560102a1
line wrap: on
line diff
--- 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;