changeset 203:258af0c4dc28

* Fix crash in short spectrogram paint * Fix incorrect apparent end point for waveforms
author Chris Cannam
date Wed, 14 Feb 2007 17:52:06 +0000
parents cec1f78fbfca
children 942cfa1df966
files layer/Layer.cpp layer/SpectrogramLayer.cpp
diffstat 2 files changed, 22 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/layer/Layer.cpp	Fri Feb 09 11:32:34 2007 +0000
+++ b/layer/Layer.cpp	Wed Feb 14 17:52:06 2007 +0000
@@ -43,7 +43,12 @@
 QString
 Layer::getLayerPresentationName() const
 {
-    QString layerName = objectName();
+//    QString layerName = objectName();
+
+    LayerFactory *factory = LayerFactory::getInstance();
+    QString layerName = factory->getLayerPresentationName
+        (factory->getLayerType(this));
+
     QString modelName;
     if (getModel()) modelName = getModel()->objectName();
 	    
--- a/layer/SpectrogramLayer.cpp	Fri Feb 09 11:32:34 2007 +0000
+++ b/layer/SpectrogramLayer.cpp	Wed Feb 14 17:52:06 2007 +0000
@@ -1629,11 +1629,18 @@
     int x0 = 0, x1 = v->width();
     float s00 = 0, s01 = 0, s10 = 0, s11 = 0;
     
-    getXBinRange(v, x0, s00, s01);
-    getXBinRange(v, x1, s10, s11);
+    if (!getXBinRange(v, x0, s00, s01)) {
+        s00 = s01 = m_model->getStartFrame() / getWindowIncrement();
+    }
+
+    if (!getXBinRange(v, x1, s10, s11)) {
+        s10 = s11 = m_model->getEndFrame() / getWindowIncrement();
+    }
 
     int s0 = int(std::min(s00, s10) + 0.0001);
-    int s1 = int(std::max(s01, s11));
+    int s1 = int(std::max(s01, s11) + 0.0001);
+
+//    std::cerr << "SpectrogramLayer::updateViewMagnitudes: x0 = " << x0 << ", x1 = " << x1 << ", s00 = " << s00 << ", s11 = " << s11 << " s0 = " << s0 << ", s1 = " << s1 << std::endl;
 
     if (m_columnMags.size() <= s1) {
         m_columnMags.resize(s1 + 1);
@@ -2081,6 +2088,12 @@
 
             if (mag.isSet()) {
 
+
+                if (s >= m_columnMags.size()) {
+                    std::cerr << "INTERNAL ERROR: " << s << " >= "
+                              << m_columnMags.size() << " at SpectrogramLayer.cpp:2087" << std::endl;
+                }
+
                 m_columnMags[s].sample(mag);
 
                 if (overallMag.sample(mag)) {