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.
This commit is contained in:
Eric Price
2024-09-24 02:09:29 +02:00
committed by GitHub
parent 0f2da45cbd
commit 7f44a0e4b2

View File

@@ -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.