Solved QtCreator: starting QML application with RUN vs DEBUG affects locale
-
The following QML code, launched in QtCreator application in RUN vs DEBUG mode, affects locale behaviour:
console.log(Qt.locale().name, Qt.locale().groupSeparator, Qt.locale().decimalPoint)
When starting the application in RUN ( Ctrl+R, or green arrow icon) prints
en-US , .
When starting the application in DEBUG ( F5 or green arrow with a bug icon) prints
en-US . ,
Note how the group separator and decimal point appear reversed. The numeric pad in Virtual Keyboard shows the dot or comma keys accordingly. The DEBUG launch is the expected behaviour.
I am using Qt Creator 4.10.0
Based on Qt 5.13.1 (GCC 5.3.1 20160406 (Red Hat 5.3.1-6), 64 bit)
Built on Sep 4 2019 04:47:37In project options, Build environment = Run environment = System environment:
declare -x LANG="en_US.UTF-8" declare -x LANGUAGE="en_US" declare -x LC_ADDRESS="it_IT.UTF-8" declare -x LC_IDENTIFICATION="it_IT.UTF-8" declare -x LC_MEASUREMENT="it_IT.UTF-8" declare -x LC_MONETARY="it_IT.UTF-8" declare -x LC_NAME="it_IT.UTF-8" declare -x LC_NUMERIC="it_IT.UTF-8" declare -x LC_PAPER="it_IT.UTF-8" declare -x LC_TELEPHONE="it_IT.UTF-8" declare -x GDMSESSION="xfce" declare -x GDM_LANG="en_US" declare -x MANDATORY_PATH="/usr/share/gconf/xfce.mandatory.path" declare -x OLDPWD declare -x PATH="/home/alberto/Qt5.12.5/5.12.5/gcc_64/bin:/usr/bin:/home/alberto/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin" declare -x PWD="/home/alberto" ( etc. )
What am I doing wrong?
-
@bitbang unfortunately this is needed as gdb (the debugger) does not work correctly with foreign locales (e.g. swaps ',' and '.' and therefore formats float numbers in a way Creator cannot parse). unfortunately that affects user programs too.
I have no idea how to solve that...
Regards
-
Found myself an explanation: dumping the runtime environment within the application ( that is, capturing QProcess output of the "printenv" command), shows that when QtCreator runs the program in debug mode:
LC_NUMERIC=C
Wheras launching the same application in run mode results in:
LC_NUMERIC=it_IT.UTF-8
Apparently, debug mode overrides what shown in QtCreator's "Build Settings /Build Environment" (I checked "Use build settings" in "Build SettingsRun Environment")
Any hint?
-
@bitbang unfortunately this is needed as gdb (the debugger) does not work correctly with foreign locales (e.g. swaps ',' and '.' and therefore formats float numbers in a way Creator cannot parse). unfortunately that affects user programs too.
I have no idea how to solve that...
Regards
-
@aha_1980 Setting as solved because this puts a rationale to the observed behavior. So, when in doubt, I can assume debugger runs differ slightly from actual end-user runs. Thank you!