From 753e9481cbb09535823ec2fdb181c101058747fd Mon Sep 17 00:00:00 2001 From: 0penBrain <48731257+0penBrain@users.noreply.github.com> Date: Thu, 23 Feb 2023 20:05:28 +0100 Subject: [PATCH] [BugFix] Sketcher: correctly handles angle strings displayed at cursor for all locales, fixes #8611 --- src/Mod/Sketcher/Gui/Utils.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Mod/Sketcher/Gui/Utils.cpp b/src/Mod/Sketcher/Gui/Utils.cpp index 9e1efb3ed0..0e21358b49 100644 --- a/src/Mod/Sketcher/Gui/Utils.cpp +++ b/src/Mod/Sketcher/Gui/Utils.cpp @@ -581,18 +581,19 @@ std::string SketcherGui::angleToDisplayFormat(double value, int digits) //we always use use U+00B0 (°) as the unit of measure for angles in //single unit schema. Will need a change to support rads or grads. - QString qUnitString = QString::fromUtf8("°"); + auto qUnitString = QString::fromUtf8("°"); + auto decimalSep = QLocale().decimalPoint(); //get the numeric part of the user string QRegularExpression rxNoUnits( - QString::fromUtf8("(\\d*\\.?\\d*)(\\D*)$"));// number + non digits at end of string + QString::fromUtf8("(\\d*\\%1?\\d*)(\\D*)$").arg(decimalSep));// number + non digits at end of string QRegularExpressionMatch match = rxNoUnits.match(qUserString); if (!match.hasMatch()) { //no units in userString? return Base::Tools::toStdString(qUserString); } QString matched = match.captured(1);//matched is the numeric part of user string - int dpPos = matched.indexOf(QLocale().decimalPoint()); + int dpPos = matched.indexOf(decimalSep); if (dpPos < 0) { //no decimal separator (ie an integer), return all the digits return Base::Tools::toStdString(matched + qUnitString);