diff layer/SpectrogramLayer.cpp @ 29:9f55af9676b4

* Add ffwd/rewind * Abstract out MultiSelection
author Chris Cannam
date Wed, 08 Feb 2006 17:59:16 +0000
parents 202d1dca67d2
children fc802f7b112e
line wrap: on
line diff
--- a/layer/SpectrogramLayer.cpp	Mon Feb 06 17:24:52 2006 +0000
+++ b/layer/SpectrogramLayer.cpp	Wed Feb 08 17:59:16 2006 +0000
@@ -49,6 +49,7 @@
     m_fillThread(0),
     m_updateTimer(0),
     m_lastFillExtent(0),
+    m_dormant(false),
     m_exiting(false)
 {
     if (config == MelodicRange) {
@@ -594,6 +595,19 @@
 }
 
 void
+SpectrogramLayer::setLayerDormant()
+{
+    m_mutex.lock();
+    m_dormant = true;
+    delete m_cache;
+    m_cache = 0;
+    m_pixmapCacheInvalid = true;
+    delete m_pixmapCache;
+    m_pixmapCache = 0;
+    m_mutex.unlock();
+}
+
+void
 SpectrogramLayer::cacheInvalid()
 {
     m_cacheInvalid = true;
@@ -866,7 +880,7 @@
 
 //	std::cerr << "SpectrogramLayer::CacheFillThread::run in loop" << std::endl;
 
-	if (m_layer.m_model && m_layer.m_cacheInvalid) {
+	if (m_layer.m_model && m_layer.m_cacheInvalid && !m_layer.m_dormant) {
 
 //	    std::cerr << "SpectrogramLayer::CacheFillThread::run: something to do" << std::endl;
 
@@ -1222,6 +1236,13 @@
 	return;
     }
 
+    if (m_dormant) {
+	std::cerr << "SpectrogramLayer::paint(): Layer is dormant, de-hibernating" << std::endl;
+	m_dormant = false;
+	((SpectrogramLayer *)this)->fillCache();
+	return;
+    }
+
 #ifdef DEBUG_SPECTROGRAM_REPAINT
     std::cerr << "SpectrogramLayer::paint(): About to lock" << std::endl;
 #endif