From 06a909e00430087be70207d5dc303523bc22fa88 Mon Sep 17 00:00:00 2001 From: mpa Date: Wed, 18 Jan 2017 16:13:59 +0300 Subject: [PATCH] - delete deprecated code - fix problem with reload study --- .../gui/input/howtos_and_best_practives.doc | 4 ++-- src/LightApp/LightApp_Application.cxx | 3 ++- src/SalomeApp/SalomeApp_Application.cxx | 2 +- src/SalomeApp/SalomeApp_Engine_i.cxx | 14 ++++++------ src/SalomeApp/SalomeApp_Study.cxx | 22 ++++++++----------- src/Session/Session_Session_i.cxx | 12 +++++----- src/Session/Session_Session_i.hxx | 1 - 7 files changed, 26 insertions(+), 32 deletions(-) diff --git a/doc/salome/gui/input/howtos_and_best_practives.doc b/doc/salome/gui/input/howtos_and_best_practives.doc index e064bf281..b601e80e3 100644 --- a/doc/salome/gui/input/howtos_and_best_practives.doc +++ b/doc/salome/gui/input/howtos_and_best_practives.doc @@ -159,12 +159,12 @@ useCaseIter->UnRegister(); useCaseBuilder->UnRegister(); \endcode -\section use_case_compatibility Remark about compatibility with existing studies +\section use_case_compatibility Remark about compatibility with existing study If you decide to switch your module to the use case builder approach to provide customization for the data tree representation, you must take care of compatibility with existing SALOME studies. Basically it means that you have to add -a simple code to \c Load() (and \c LoadASCII() if necessary) method +a simple code to \c Load() method of your module, which adds tree node attributes to all data entities in the data tree of your module. The simplest way to do this is to iterate through all data items and recursively add them to diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 4fffbcb10..7a22373ac 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -5097,7 +5097,8 @@ bool LightApp_Application::checkExistingDoc() { bool result = true; if( activeStudy() ) { - int answer = SUIT_MessageBox::question( desktop(), + int answer = !activeStudy()->isModified() ? 1 : + SUIT_MessageBox::question( desktop(), tr( "APPCLOSE_CAPTION" ), tr( "STUDYCLOSE_DESCRIPTION" ), tr( "APPCLOSE_SAVE" ), diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index 3a5e17cce..b1fb863f9 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -557,7 +557,7 @@ void SalomeApp_Application::onDesktopMessage( const QString& message ) } if (message.indexOf("studyCleared") == 0) { // Disconnect GUI from active study, because it was closed on DS side. - if (activeStudy() && activeStudy()->isModified()) { + if (activeStudy()) { closeActiveDoc( false ); // Disable 'Connect' action QAction* a = action( ConnectId ); diff --git a/src/SalomeApp/SalomeApp_Engine_i.cxx b/src/SalomeApp/SalomeApp_Engine_i.cxx index 3d5776a99..57d4340f3 100644 --- a/src/SalomeApp/SalomeApp_Engine_i.cxx +++ b/src/SalomeApp/SalomeApp_Engine_i.cxx @@ -86,16 +86,16 @@ SALOMEDS::TMPFile* SalomeApp_Engine_i::Save (SALOMEDS::SComponent_ptr theCompone std::string aTmpDir = myListOfFiles[0]; // Create a list to store names of created files - SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames; - aSeq->length(n); + ListOfFiles aSeq; + aSeq.reserve(n); for (int i = 0; i < n; i++) - aSeq[i] = CORBA::string_dup(myListOfFiles[i + 1].c_str()); + aSeq.push_back(CORBA::string_dup(myListOfFiles[i + 1].c_str())); // Convert a file to the byte stream - aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.c_str(), aSeq.in(), isMultiFile); + aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.c_str(), aSeq, isMultiFile); // Remove the files and tmp directory, created by the component storage procedure - if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aSeq.in(), true); + if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aSeq, true); } return aStreamFile._retn(); @@ -121,11 +121,11 @@ CORBA::Boolean SalomeApp_Engine_i::Load (SALOMEDS::SComponent_ptr theComponent, // Convert the byte stream theStream to a files and place them in the tmp directory. // The files and temporary directory must be deleted by the component loading procedure. - SALOMEDS::ListOfFileNames_var aSeq = + ListOfFiles aSeq = SALOMEDS_Tool::PutStreamToFiles(theFile, aTmpDir.c_str(), isMultiFile); // Store list of file names to be used by the component loading procedure - const int n = aSeq->length() + 1; + const int n = aSeq.size() + 1; ListOfFiles listOfFiles (n); listOfFiles[0] = aTmpDir; for (int i = 1; i < n; i++) diff --git a/src/SalomeApp/SalomeApp_Study.cxx b/src/SalomeApp/SalomeApp_Study.cxx index 36acbe03d..beabade90 100644 --- a/src/SalomeApp/SalomeApp_Study.cxx +++ b/src/SalomeApp/SalomeApp_Study.cxx @@ -427,7 +427,7 @@ QString SalomeApp_Study::studyName() const // it can be changed outside of GUI // TEMPORARILY SOLUTION: better to be implemented with help of SALOMEDS observers if ( studyDS() ) { - QString newName = QString::fromUtf8(studyDS()->Name().c_str()); + QString newName = QString::fromUtf8(studyDS()->URL().c_str()); if ( LightApp_Study::studyName() != newName ) { SalomeApp_Study* that = const_cast( this ); that->setStudyName( newName ); @@ -480,7 +480,7 @@ bool SalomeApp_Study::createDocument( const QString& theStr ) return false; setStudyDS( study ); - setStudyName( QString::fromUtf8(study->Name().c_str()) ); + setStudyName( QString::fromUtf8(study->URL().c_str()) ); // create myRoot SalomeApp_RootObject* aRoot=new SalomeApp_RootObject( this ); @@ -666,9 +666,7 @@ bool SalomeApp_Study::saveDocumentAs( const QString& theFileName ) bool isMultiFile = resMgr->booleanValue( "Study", "multi_file", false ); bool isAscii = resMgr->booleanValue( "Study", "ascii_file", false ); - bool res = (isAscii ? - studyDS()->SaveAsASCII( theFileName.toUtf8().data(), isMultiFile ) : - studyDS()->SaveAs ( theFileName.toUtf8().data(), isMultiFile )) + bool res = studyDS()->SaveAs( theFileName.toUtf8().data(), isMultiFile, isAscii ) && CAM_Study::saveDocumentAs( theFileName ); res = res && saveStudyData(theFileName); @@ -711,9 +709,7 @@ bool SalomeApp_Study::saveDocument() bool isMultiFile = resMgr->booleanValue( "Study", "multi_file", false ); bool isAscii = resMgr->booleanValue( "Study", "ascii_file", false ); - bool res = (isAscii ? - studyDS()->SaveASCII( isMultiFile ) : - studyDS()->Save ( isMultiFile )) && CAM_Study::saveDocument(); + bool res = studyDS()->Save( isMultiFile, isAscii ) && CAM_Study::saveDocument(); res = res && saveStudyData(studyName()); if ( res ) @@ -1169,17 +1165,17 @@ void SalomeApp_Study::RemoveTemporaryFiles ( const char* theModuleName, const bo if (isMultiFile) return; - std::vector aListOfFiles = GetListOfFiles( theModuleName ); + SALOMEDS_Tool::ListOfFiles aListOfFiles = GetListOfFiles( theModuleName ); if (aListOfFiles.size() > 0) { std::string aTmpDir = aListOfFiles[0]; const int n = aListOfFiles.size() - 1; - SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames; - aSeq->length(n); + std::vector aSeq; + aSeq.reserve(n); for (int i = 0; i < n; i++) - aSeq[i] = CORBA::string_dup(aListOfFiles[i + 1].c_str()); + aSeq.push_back(CORBA::string_dup(aListOfFiles[i + 1].c_str())); - SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aSeq.in(), true); + SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aSeq, true); } } diff --git a/src/Session/Session_Session_i.cxx b/src/Session/Session_Session_i.cxx index 101be1989..d82cefc87 100755 --- a/src/Session/Session_Session_i.cxx +++ b/src/Session/Session_Session_i.cxx @@ -65,7 +65,6 @@ SALOME_Session_i::SALOME_Session_i(int argc, _argc = argc ; _argv = argv ; _isGUI = false ; - _runningStudies= 0 ; _orb = CORBA::ORB::_duplicate(orb) ; _poa = PortableServer::POA::_duplicate(poa) ; _GUIMutex = GUIMutex; @@ -206,7 +205,7 @@ void SALOME_Session_i::Shutdown() /*! Send a SALOME::StatSession structure (see idl) to the client - (number of running studies and presence of GUI) + (presence of GUI) */ /*class QtLock { @@ -220,24 +219,23 @@ SALOME::StatSession SALOME_Session_i::GetStatSession() { // update Session state _GUIMutex->lock(); + int activeStudy = 0; - _runningStudies = 0; { //QtLock lock; _isGUI = SUIT_Session::session(); if ( _isGUI && SUIT_Session::session()->activeApplication() ) - _runningStudies = SUIT_Session::session()->activeApplication()->getNbStudies(); + activeStudy = SUIT_Session::session()->activeApplication()->getNbStudies(); } // getting stat info - SALOME::StatSession_var myStats = new SALOME::StatSession ; - if (_runningStudies) + SALOME::StatSession_var myStats = new SALOME::StatSession; + if (activeStudy) myStats->state = SALOME::running ; else if (_isShuttingDown) myStats->state = SALOME::shutdown ; else myStats->state = SALOME::asleep ; - myStats->runningStudies = _runningStudies ; myStats->activeGUI = _isGUI ; _GUIMutex->unlock(); diff --git a/src/Session/Session_Session_i.hxx b/src/Session/Session_Session_i.hxx index ab8d96721..1fbcc4d42 100755 --- a/src/Session/Session_Session_i.hxx +++ b/src/Session/Session_Session_i.hxx @@ -92,7 +92,6 @@ protected: CORBA::Boolean _isGUI ; QMutex* _GUIMutex ; QWaitCondition* _GUILauncher; - int _runningStudies ; CORBA::ORB_var _orb; PortableServer::POA_var _poa; bool _isShuttingDown; -- 2.39.2