diff layer/SpectrogramLayer.cpp @ 34:c43f2c4f66f2

* As previous commit
author Chris Cannam
date Fri, 17 Feb 2006 18:11:08 +0000
parents 651e4e868bcc
children 10ba9276a315
line wrap: on
line diff
--- a/layer/SpectrogramLayer.cpp	Fri Feb 17 18:04:26 2006 +0000
+++ b/layer/SpectrogramLayer.cpp	Fri Feb 17 18:11:08 2006 +0000
@@ -79,9 +79,14 @@
 void
 SpectrogramLayer::setModel(const DenseTimeValueModel *model)
 {
+    std::cerr << "SpectrogramLayer(" << this << "): setModel(" << model << ")" << std::endl;
+
     m_mutex.lock();
     m_model = model;
-    delete m_cache;
+    delete m_cache; //!!! hang on, this isn't safe to do here is it? 
+		    // we need some sort of guard against the fill
+		    // thread trying to read the defunct model too.
+		    // should we use a scavenger?
     m_cache = 0;
     m_mutex.unlock();
 
@@ -605,10 +610,12 @@
 	m_mutex.lock();
 	m_dormant = true;
 
-	delete m_cache;
-	m_cache = 0;
+//	delete m_cache;
+//	m_cache = 0;
 	
+	m_cacheInvalid = true;
 	m_pixmapCacheInvalid = true;
+	m_cachedInitialVisibleArea = false;
 	delete m_pixmapCache;
 	m_pixmapCache = 0;
 	
@@ -828,7 +835,7 @@
 
     fftw_execute(plan);
 
-    if (lock) m_mutex.lock();
+//    if (lock) m_mutex.lock();
     bool interrupted = false;
 
     for (size_t i = 0; i < windowSize / 2; ++i) {
@@ -877,7 +884,7 @@
 	m_cache->setValueAt(column, i, value + 1);
     }
 
-    if (lock) m_mutex.unlock();
+//    if (lock) m_mutex.unlock();
     return !interrupted;
 }
 
@@ -953,7 +960,14 @@
 
 //	std::cerr << "SpectrogramLayer::CacheFillThread::run in loop" << std::endl;
 
-	if (m_layer.m_model && m_layer.m_cacheInvalid && !m_layer.m_dormant) {
+	if (m_layer.m_dormant) {
+
+	    if (m_layer.m_cacheInvalid) {
+		delete m_layer.m_cache;
+		m_layer.m_cache = 0;
+	    }
+
+	} else if (m_layer.m_model && m_layer.m_cacheInvalid) {
 
 //	    std::cerr << "SpectrogramLayer::CacheFillThread::run: something to do" << std::endl;