Salome HOME
bos #23995 Porting to Qt 5.12: move locale settings from spin boxes to global level... vsr/23995_bad_alloc
authorvsr <vsr@opencascade.com>
Wed, 31 Mar 2021 07:45:11 +0000 (10:45 +0300)
committervsr <vsr@opencascade.com>
Wed, 31 Mar 2021 07:49:28 +0000 (10:49 +0300)
CMakeLists.txt
src/Qtx/QtxDoubleSpinBox.cxx
src/Qtx/QtxIntSpinBox.cxx
src/SUITApp/SUITApp.cxx
src/Session/SALOME_Session_Server.cxx

index 8862e9c44441805c6e63c0f3e09aa9e7ad6fa2d5..088d8d2d0b819d34ebdf389c488a3310b5f9b309 100644 (file)
@@ -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()
 
index 7a2bf0ed94fd18f4efbc807bef3a2ab0325de18c..6aefbaf3005e8c1a8635fd84defa7dfb8d591258 100644 (file)
@@ -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 );
index 4a659daad5db52de6497c5903274f81ca5c6d24c..fbe5850c947a3e1c7c41fc103e607c50ec89216e 100644 (file)
@@ -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 );
index ae244b8906b746b8883fd71dd3cb4bc5ec30b0ad..f5259a15bcee639e3e5e5538d97affe9c737f7a6 100644 (file)
@@ -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 )
index f0420532aa596778738046f5fc342c7375d9378a..fc1db2ac19c6f2ffec16236060e272254b92857b 100644 (file)
@@ -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