changeset 1378:f08a3b8cdb9d

Avoid nan/inf values (and consequent crash) in colour scale range
author Chris Cannam
date Tue, 06 Nov 2018 13:35:47 +0000
parents d18ca558049e
children b6cca362bbf4 78eecb19e688
files layer/Colour3DPlotLayer.cpp
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/layer/Colour3DPlotLayer.cpp	Tue Nov 06 13:34:56 2018 +0000
+++ b/layer/Colour3DPlotLayer.cpp	Tue Nov 06 13:35:47 2018 +0000
@@ -1049,9 +1049,16 @@
                 << " (model min = " << m_model->getMinimumLevel()
                 << ", max = " << m_model->getMaximumLevel() << ")"
                 << endl;
-        
+
         if (maxValue <= minValue) {
             maxValue = minValue + 0.1f;
+
+            if (!(maxValue > minValue)) { // one of them must be NaN or Inf
+                SVCERR << "WARNING: Colour3DPlotLayer::getRenderer: resetting "
+                       << "minValue and maxValue to zero and one" << endl;
+                minValue = 0.f;
+                maxValue = 1.f;
+            }
         }
 
         cparams.threshold = minValue;