Salome HOME
[SALOME platform 0019880]: EDF GEM SMESH 728: SIGSEV while dumping the study
[modules/geom.git] / src / DlgRef / DlgRef_SpinBox.cxx
index 35bec55ba5db9a59950f306a6db8cfc2cb04970e..2a595b12d63c754b1c4877c2e5d578542ae36357 100644 (file)
@@ -29,6 +29,7 @@
 #include "DlgRef_SpinBox.h"
 
 #include <qvalidator.h>
+#include <math.h>
 
 //=================================================================================
 // class    : DlgRef_SpinBox()
@@ -105,9 +106,22 @@ void DlgRef_SpinBox::RangeStepAndValidator(double min, double max,double step,
 
 QString DlgRef_SpinBox::PrintDoubleValue (double theValue, int thePrecision)
 {
+  const double prec = 1e-12;
+
   QString aRes;
   aRes.setNum(theValue, 'g', thePrecision);
 
+  if ( prec > 0 ) {
+    int p = 0;
+    while ( p < thePrecision ) {
+      aRes.setNum( theValue, 'g', p++ );
+      double v = aRes.toDouble();
+      double err = fabs( theValue - v );
+      if ( err > 0 && err <= prec )
+       break;
+    }
+  }
+
   // remove trailing zeroes
   QString delim( "." );