From a422b0da8bca68f87801db9c2ef4819cbe573993 Mon Sep 17 00:00:00 2001
From: Joachim Wuttke <j.wuttke@fz-juelich.de>
Date: Tue, 5 Dec 2023 21:59:32 +0100
Subject: [PATCH] toString special case 0

---
 GUI/View/Numeric/DoubleSpinBox.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/GUI/View/Numeric/DoubleSpinBox.cpp b/GUI/View/Numeric/DoubleSpinBox.cpp
index 130c42a6aa4..2635589ee32 100644
--- a/GUI/View/Numeric/DoubleSpinBox.cpp
+++ b/GUI/View/Numeric/DoubleSpinBox.cpp
@@ -17,17 +17,20 @@
 #include "Base/Util/StringUtil.h"
 #include "GUI/Model/Descriptor/DoubleProperty.h"
 #include "GUI/View/Numeric/NumberUtil.h"
+#include <QRegularExpression>
 #include <QWheelEvent>
 
 namespace {
 
 QString toString(double val, int decimal_points = 4)
 {
+    if (val == 0)
+        return "0";
+
     QString result = (val >= 1000 || val < 0.1) ? QString::number(val, 'e', decimal_points)
                                                 : QString::number(val, 'f', decimal_points);
 
-    return result.replace(QRegularExpression("(\\.?0+)?((e{1}[\\+|-]{1})(0+)?([1-9]{1}.*))?$"),
-                          "\\3\\5");
+    return result.replace(QRegularExpression("(\\.?0+)?((e[\\+|-])(0+)?([1-9].*))?$"), "\\3\\5");
 }
 
 } // namespace
-- 
GitLab