From ec9d3e9d1a8653f9a193ebe81bad943de647ef3e Mon Sep 17 00:00:00 2001 From: vsv Date: Wed, 15 Jul 2015 09:50:48 +0300 Subject: [PATCH] Issue #652: Qt can convert to double a string as with '.' as with ',', but method value() of SpinBox returns non correct value if the decimal point doesn't correspond to locale. We have to check this situation. --- src/ModuleBase/ModuleBase_ParamSpinBox.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/ModuleBase/ModuleBase_ParamSpinBox.cpp b/src/ModuleBase/ModuleBase_ParamSpinBox.cpp index 2b3544917..55543e80e 100644 --- a/src/ModuleBase/ModuleBase_ParamSpinBox.cpp +++ b/src/ModuleBase/ModuleBase_ParamSpinBox.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -179,6 +180,14 @@ bool ModuleBase_ParamSpinBox::hasVariable(const QString& theText) const //} bool aHasDigit = false; theText.toDouble(&aHasDigit); + if (aHasDigit) { + QLocale aLoc; // create default locale + QChar aDecPnt = aLoc.decimalPoint(); + if (aDecPnt == '.') + aHasDigit = theText.contains(aDecPnt) || (!theText.contains(',')); + else if (aDecPnt == ',') + aHasDigit = theText.contains(aDecPnt) || (!theText.contains('.')); + } return !aHasDigit; } -- 2.39.2