From: vsr Date: Wed, 31 Mar 2021 07:45:11 +0000 (+0300) Subject: bos #23995 Porting to Qt 5.12: move locale settings from spin boxes to global level... X-Git-Tag: V9_7_0a1~10 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8d7c6f2eb4937428e0145ea1dbea48c99f907856;p=modules%2Fgui.git bos #23995 Porting to Qt 5.12: move locale settings from spin boxes to global level (because of crash in qt 5.12) --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 8862e9c44..088d8d2d0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -236,6 +236,9 @@ IF(NOT SALOME_USE_SALOMEOBJECT) ADD_DEFINITIONS("-DDISABLE_SALOMEOBJECT") ENDIF() +# Other global definitions +ADD_DEFINITIONS("-DGLOBAL_DOUBLE_CONVERSION") + # Detection summary: SALOME_PACKAGE_REPORT_AND_CHECK() diff --git a/src/Qtx/QtxDoubleSpinBox.cxx b/src/Qtx/QtxDoubleSpinBox.cxx index 7a2bf0ed9..6aefbaf30 100644 --- a/src/Qtx/QtxDoubleSpinBox.cxx +++ b/src/Qtx/QtxDoubleSpinBox.cxx @@ -75,11 +75,14 @@ QtxDoubleSpinBox::QtxDoubleSpinBox( QWidget* parent ) : QDoubleSpinBox( parent ), myCleared( false ) { +#if !defined(GLOBAL_DOUBLE_CONVERSION) // VSR 01/07/2010: Disable thousands separator for spin box // (to avoid incosistency of double-2-string and string-2-double conversion) + // see issue 14540 (old id 21219) QLocale loc; loc.setNumberOptions(loc.numberOptions() | QLocale::OmitGroupSeparator | QLocale::RejectGroupSeparator); setLocale(loc); +#endif // Use precision equal to default Qt decimals myPrecision = decimals(); @@ -104,11 +107,14 @@ QtxDoubleSpinBox::QtxDoubleSpinBox( double min, double max, double step, QWidget : QDoubleSpinBox( parent ), myCleared( false ) { +#if !defined(GLOBAL_DOUBLE_CONVERSION) // VSR 01/07/2010: Disable thousands separator for spin box // (to avoid incosistency of double-2-string and string-2-double conversion) + // see issue 14540 (old id 21219) QLocale loc; loc.setNumberOptions(loc.numberOptions() | QLocale::OmitGroupSeparator | QLocale::RejectGroupSeparator); setLocale(loc); +#endif // Use precision equal to default Qt decimals myPrecision = decimals(); @@ -141,11 +147,14 @@ QtxDoubleSpinBox::QtxDoubleSpinBox( double min, double max, double step, int pre myCleared( false ), myPrecision( prec ) { +#if !defined(GLOBAL_DOUBLE_CONVERSION) // VSR 01/07/2010: Disable thousands separator for spin box // (to avoid incosistency of double-2-string and string-2-double conversion) + // see issue 14540 (old id 21219) QLocale loc; loc.setNumberOptions(loc.numberOptions() | QLocale::OmitGroupSeparator | QLocale::RejectGroupSeparator); setLocale(loc); +#endif setDecimals( dec ); setMinimum( min ); diff --git a/src/Qtx/QtxIntSpinBox.cxx b/src/Qtx/QtxIntSpinBox.cxx index 4a659daad..fbe5850c9 100644 --- a/src/Qtx/QtxIntSpinBox.cxx +++ b/src/Qtx/QtxIntSpinBox.cxx @@ -61,11 +61,14 @@ QtxIntSpinBox::QtxIntSpinBox( QWidget* parent ) : QSpinBox( parent ), myCleared( false ) { +#if !defined(GLOBAL_DOUBLE_CONVERSION) // VSR 01/07/2010: Disable thousands separator for spin box // (to avoid incosistency of double-2-string and string-2-double conversion) + // see issue 14540 (old id 21219) QLocale loc; loc.setNumberOptions(loc.numberOptions() | QLocale::OmitGroupSeparator | QLocale::RejectGroupSeparator); setLocale(loc); +#endif setCorrectionMode( QSpinBox::CorrectToNearestValue ); connect( lineEdit(), SIGNAL( textChanged( const QString& ) ), @@ -87,11 +90,14 @@ QtxIntSpinBox::QtxIntSpinBox( int min, int max, int step, QWidget* parent ) : QSpinBox( parent ), myCleared( false ) { +#if !defined(GLOBAL_DOUBLE_CONVERSION) // VSR 01/07/2010: Disable thousands separator for spin box // (to avoid incosistency of double-2-string and string-2-double conversion) + // see issue 14540 (old id 21219) QLocale loc; loc.setNumberOptions(loc.numberOptions() | QLocale::OmitGroupSeparator | QLocale::RejectGroupSeparator); setLocale(loc); +#endif setMinimum( min ); setMaximum( max ); diff --git a/src/SUITApp/SUITApp.cxx b/src/SUITApp/SUITApp.cxx index ae244b890..f5259a15b 100644 --- a/src/SUITApp/SUITApp.cxx +++ b/src/SUITApp/SUITApp.cxx @@ -271,6 +271,15 @@ int main( int argc, char* argv[] ) QLocale::setDefault( QLocale::c() ); resMgr.setWorkingMode( ResourceMgr::IgnoreUserValues ); +#if defined(GLOBAL_DOUBLE_CONVERSION) + // VSR 30/03/2021: moved here from QtxDoubleSpinBox/QtxIntSpinBox because of crash on Qt 5.12. + // Disable thousands separator for spin box + // see issue 14540 (old id 21219) + QLocale locale; + locale.setNumberOptions(locale.numberOptions() | QLocale::OmitGroupSeparator | QLocale::RejectGroupSeparator); + QLocale::setDefault(locale); +#endif + if ( !debugExceptions ) debugExceptions = resMgr.booleanValue( "launch", "noexcepthandler", false ); if ( !noSplash ) diff --git a/src/Session/SALOME_Session_Server.cxx b/src/Session/SALOME_Session_Server.cxx index f0420532a..fc1db2ac1 100644 --- a/src/Session/SALOME_Session_Server.cxx +++ b/src/Session/SALOME_Session_Server.cxx @@ -507,6 +507,15 @@ int AbstractGUIAppMain(int argc, char **argv) QLocale::setDefault(QLocale::c()); resMgr.setWorkingMode(ResourceMgr::IgnoreUserValues); +#if defined(GLOBAL_DOUBLE_CONVERSION) + // VSR 30/03/2021: moved here from QtxDoubleSpinBox/QtxIntSpinBox because of crash on Qt 5.12. + // Disable thousands separator for spin box + // see issue 14540 (old id 21219) + QLocale locale; + locale.setNumberOptions(locale.numberOptions() | QLocale::OmitGroupSeparator | QLocale::RejectGroupSeparator); + QLocale::setDefault(locale); +#endif + bool isGUI = boolCmdOption("--show-desktop", "--hide-desktop", true); // true by default bool isSplash = boolCmdOption("--show-splash", "--hide-splash", true); // true by default