From 7f44a0e4b2d3b093801476824ac2a21592cb1fe9 Mon Sep 17 00:00:00 2001 From: Eric Price <32105268+AIRCAP@users.noreply.github.com> Date: Tue, 24 Sep 2024 02:09:29 +0200 Subject: [PATCH] CLI: Enforce LC_NUMERIC=C on Posix systems (#16724) (#16763) * Enforce LC_NUMERIC=C on Posix systems (#16724) Initialising Qt with native LC_NUMERIC affects XML import on CLI (freecad -c) This causes sketch constraints and potentially other components relying on numeric constants to break or have incorrect values. Forcing LC_NUMERIC to C avoids this issue and enforces reproducible behaviour on all locales. This does not affect the number format displayed in the GUI, as set in preferences. --- src/Main/MainGui.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Main/MainGui.cpp b/src/Main/MainGui.cpp index 62648e8b73..d56d1a842c 100644 --- a/src/Main/MainGui.cpp +++ b/src/Main/MainGui.cpp @@ -98,7 +98,9 @@ private: int main(int argc, char** argv) { #if defined(FC_OS_LINUX) || defined(FC_OS_BSD) - setlocale(LC_ALL, ""); // use native environment settings + setlocale(LC_ALL, ""); // use native environment settings + setlocale(LC_NUMERIC, "C"); // except for numbers to not break XML import + // See https://github.com/FreeCAD/FreeCAD/issues/16724 // Make sure to setup the Qt locale system before setting LANG and LC_ALL to C. // which is needed to use the system locale settings.