From 37049859b5c95eaefa95a6d0c8544550c15016ef Mon Sep 17 00:00:00 2001 From: vsr Date: Fri, 16 Oct 2015 13:39:49 +0300 Subject: [PATCH] 0023184: [CEA 1605] SALOME freezes while loading an empty study --- src/SalomeApp/SalomeApp_Application.cxx | 2 ++ src/SalomeApp/SalomeApp_Study.cxx | 28 ++++++++++++++++++------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index 309f65866..11d041cb7 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -237,6 +237,7 @@ void SalomeApp_Application::start() LightApp_Application::start(); SALOME_EventFilter::Init(); + setProperty("open_study_from_command_line", true); if ( !hdffile.isEmpty() ) // open hdf file given as parameter onOpenDoc( hdffile ); else if ( pyfiles.count() > 0 ) // create new study @@ -245,6 +246,7 @@ void SalomeApp_Application::start() if (onLoadDoc(loadStudy)) updateObjectBrowser(true); } + setProperty("open_study_from_command_line", QVariant()); #ifndef DISABLE_PYCONSOLE // import/execute python scripts diff --git a/src/SalomeApp/SalomeApp_Study.cxx b/src/SalomeApp/SalomeApp_Study.cxx index 3211ad20a..8598e2bdb 100644 --- a/src/SalomeApp/SalomeApp_Study.cxx +++ b/src/SalomeApp/SalomeApp_Study.cxx @@ -467,17 +467,23 @@ bool SalomeApp_Study::createDocument( const QString& theStr ) QString aName = newStudyName(); _PTR(Study) study; + bool showError = !application()->property("open_study_from_command_line").isValid() || + !application()->property("open_study_from_command_line").toBool(); try { study = _PTR(Study)( SalomeApp_Application::studyMgr()->NewStudy( aName.toUtf8().data() ) ); } catch(const SALOME_Exception& ex) { - SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(), - tr("ERR_ERROR"), tr(ex.what())); + application()->putInfo(tr(ex.what())); + if ( showError ) + SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(), + tr("ERR_ERROR"), tr(ex.what())); return false; } catch(...) { - SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(), - tr("ERR_ERROR"), tr("CREATE_DOCUMENT_PROBLEM")); + application()->putInfo(tr("CREATE_DOCUMENT_PROBLEM")); + if ( showError ) + SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(), + tr("ERR_ERROR"), tr("CREATE_DOCUMENT_PROBLEM")); return false; } @@ -517,17 +523,23 @@ bool SalomeApp_Study::openDocument( const QString& theFileName ) // initialize myStudyDS, read HDF file _PTR(Study) study; + bool showError = !application()->property("open_study_from_command_line").isValid() || + !application()->property("open_study_from_command_line").toBool(); try { study = _PTR(Study) ( SalomeApp_Application::studyMgr()->Open( theFileName.toUtf8().data() ) ); } catch(const SALOME_Exception& ex) { - SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(), - tr("ERR_ERROR"), tr(ex.what())); + application()->putInfo(tr(ex.what())); + if ( showError ) + SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(), + tr("ERR_ERROR"), tr(ex.what())); return false; } catch(...) { - SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(), - tr("ERR_ERROR"), tr("OPEN_DOCUMENT_PROBLEM")); + application()->putInfo(tr("OPEN_DOCUMENT_PROBLEM")); + if ( showError ) + SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(), + tr("ERR_ERROR"), tr("OPEN_DOCUMENT_PROBLEM")); return false; } -- 2.39.2