diff widgets/PluginParameterBox.cpp @ 1349:615eb28768ca zoom

Merge from default branch
author Chris Cannam
date Mon, 01 Oct 2018 15:48:20 +0100
parents 01778052e663
children c8a6fd3f9dff
line wrap: on
line diff
--- a/widgets/PluginParameterBox.cpp	Fri Sep 28 18:28:44 2018 +0100
+++ b/widgets/PluginParameterBox.cpp	Mon Oct 01 15:48:20 2018 +0100
@@ -121,6 +121,10 @@
         if (!(hint & PortHint::Logarithmic)) {
             if (qtz > 0.0) {
                 imax = int(lrintf((max - min) / qtz));
+                if (imax <= imin) {
+                    imax = 100;
+                    qtz = (max - min) / 100.f;
+                }
             } else {
                 qtz = (max - min) / 100.f;
             }
@@ -181,15 +185,22 @@
 //            dial->setValue(lrintf((value - min) / qtz));
             dial->setFixedWidth(32);
             dial->setFixedHeight(32);
-            RangeMapper *rm = 0;
-            if (hint & PortHint::Logarithmic) {
-                rm = new LogRangeMapper(imin, imax, min, max, unit);
+            if (max == min || imax == imin) {
+                SVCERR << "WARNING: for parameter \"" << name
+                       << "\" of plugin \"" << m_plugin->getName()
+                       << "\": invalid range " << min << " -> " << max
+                       << " with quantize step " << qtz << endl;
             } else {
-                rm = new LinearRangeMapper(imin, imax, min, max, unit);
+                RangeMapper *rm = 0;
+                if (hint & PortHint::Logarithmic) {
+                    rm = new LogRangeMapper(imin, imax, min, max, unit);
+                } else {
+                    rm = new LinearRangeMapper(imin, imax, min, max, unit);
+                }
+                dial->setRangeMapper(rm);
+                dial->setDefaultValue(rm->getPositionForValue(deft));
+                dial->setValue(rm->getPositionForValue(value));
             }
-            dial->setRangeMapper(rm);
-            dial->setDefaultValue(rm->getPositionForValue(deft));
-            dial->setValue(rm->getPositionForValue(value));
             dial->setShowToolTip(true);
             connect(dial, SIGNAL(valueChanged(int)),
                     this, SLOT(dialChanged(int)));