From 94f7eab1e6df4a884b0b7dbccf3f91137b68cca7 Mon Sep 17 00:00:00 2001 From: vsr Date: Fri, 18 Oct 2019 16:42:16 +0300 Subject: [PATCH] refs #17322: [CEA] Problems with persistence mechanism of light module on SALOME Save --- src/LightApp/LightApp_Study.cxx | 37 ++++++++-------- src/LightApp/LightApp_Study.h | 14 +++--- src/SalomeApp/SalomeApp_Engine_i.cxx | 44 +++++++++++-------- src/SalomeApp/SalomeApp_Engine_i.h | 11 +++-- src/SalomeApp/SalomeApp_Study.cxx | 64 ++++++++++++++++------------ src/SalomeApp/SalomeApp_Study.h | 15 ++++--- 6 files changed, 104 insertions(+), 81 deletions(-) diff --git a/src/LightApp/LightApp_Study.cxx b/src/LightApp/LightApp_Study.cxx index 1f51c1a77..f75a4b8f1 100644 --- a/src/LightApp/LightApp_Study.cxx +++ b/src/LightApp/LightApp_Study.cxx @@ -77,7 +77,7 @@ bool LightApp_Study::openDocument( const QString& theFileName ) { myDriver->ClearDriverContents(); // create files for models from theFileName - if( !openStudyData(theFileName)) + if( !openStudyData(theFileName, 0)) // 0 means persistence file return false; setRoot( new LightApp_RootObject( this ) ); // create myRoot @@ -105,7 +105,7 @@ bool LightApp_Study::openDocument( const QString& theFileName ) bool LightApp_Study::loadDocument( const QString& theStudyName ) { myDriver->ClearDriverContents(); - if( !openStudyData(theStudyName)) + if( !openStudyData(theStudyName, 0)) // 0 means persistence file return false; setRoot( new LightApp_RootObject( this ) ); // create myRoot @@ -155,7 +155,8 @@ bool LightApp_Study::saveDocumentAs( const QString& theFileName ) listOfFiles.clear(); aModel->saveAs( theFileName, this, listOfFiles ); if ( !listOfFiles.isEmpty() ) - saveModuleData(aModel->module()->name(), listOfFiles); + saveModuleData(aModel->module()->name(), 0, // 0 means persistence file + listOfFiles); // Remove files if necessary. File is removed if it was in the list of files before // saving and it is not contained in the list after saving. This provides correct @@ -186,7 +187,7 @@ bool LightApp_Study::saveDocumentAs( const QString& theFileName ) myDriver->RemoveFiles( toRemoveList, isMultiFile ); } - bool res = saveStudyData(theFileName); + bool res = saveStudyData(theFileName, 0); // 0 means persistence file res = res && CAM_Study::saveDocumentAs( theFileName ); //SRN: BugID IPAL9377, removed usage of uninitialized variable if ( res ) @@ -211,10 +212,11 @@ bool LightApp_Study::saveDocument() listOfFiles.clear(); aModel->save( listOfFiles ); - saveModuleData(aModel->module()->name(), listOfFiles); + saveModuleData(aModel->module()->name(), 0, // 0 means persistence file + listOfFiles); } - bool res = saveStudyData(studyName()); + bool res = saveStudyData(studyName(), 0); // 0 means persistence file res = res && CAM_Study::saveDocument(); if (res) emit saved( this ); @@ -324,7 +326,7 @@ void LightApp_Study::addComponent(const CAM_DataModel* dm) /*! Saves list file for module 'theModuleName' */ -void LightApp_Study::saveModuleData(QString theModuleName, QStringList theListOfFiles) +void LightApp_Study::saveModuleData(QString theModuleName, int type, QStringList theListOfFiles) { int aNb = theListOfFiles.count(); if ( aNb == 0 ) @@ -338,13 +340,13 @@ void LightApp_Study::saveModuleData(QString theModuleName, QStringList theListOf aListOfFiles[anIndex] = (*it).toUtf8().constData(); anIndex++; } - myDriver->SetListOfFiles(theModuleName.toLatin1().constData(), aListOfFiles); + SetListOfFiles(theModuleName.toLatin1().constData(), type, aListOfFiles); } /*! Gets list of file for module 'theModuleNam' */ -void LightApp_Study::openModuleData(QString theModuleName, QStringList& theListOfFiles) +void LightApp_Study::openModuleData(QString theModuleName, int /*type*/, QStringList& theListOfFiles) { std::vector aListOfFiles = myDriver->GetListOfFiles(theModuleName.toLatin1().constData()); int i, aLength = aListOfFiles.size() - 1; @@ -360,7 +362,7 @@ void LightApp_Study::openModuleData(QString theModuleName, QStringList& theListO /*! Saves data from study */ -bool LightApp_Study::saveStudyData( const QString& theFileName ) +bool LightApp_Study::saveStudyData( const QString& theFileName, int /*type*/ ) { ModelList list; dataModels( list ); SUIT_ResourceMgr* resMgr = application()->resourceMgr(); @@ -375,7 +377,7 @@ bool LightApp_Study::saveStudyData( const QString& theFileName ) /*! Opens data for study */ -bool LightApp_Study::openStudyData( const QString& theFileName ) +bool LightApp_Study::openStudyData( const QString& theFileName, int /*type*/ ) { SUIT_ResourceMgr* resMgr = application()->resourceMgr(); if( !resMgr ) @@ -395,7 +397,8 @@ bool LightApp_Study::openDataModel( const QString& studyName, CAM_DataModel* dm return false; QStringList listOfFiles; - openModuleData(dm->module()->name(), listOfFiles); + openModuleData(dm->module()->name(), 0, // 0 means persistence file + listOfFiles); if (dm && dm->open(studyName, this, listOfFiles)) { // Something has been read -> create data model tree LightApp_DataModel* aDM = dynamic_cast( dm ); @@ -419,11 +422,9 @@ std::string LightApp_Study::GetTmpDir (const char* theURL, \return list of files necessary for module \param theModuleName - name of module */ -std::vector LightApp_Study::GetListOfFiles(const char* theModuleName) const +std::vector LightApp_Study::GetListOfFiles(const char* theModuleName, int /*type*/) const { - std::vector aListOfFiles; - aListOfFiles = myDriver->GetListOfFiles(theModuleName); - return aListOfFiles; + return myDriver->GetListOfFiles(theModuleName); } /*! @@ -431,7 +432,7 @@ std::vector LightApp_Study::GetListOfFiles(const char* theModuleNam \param theModuleName - name of module \param theListOfFiles - list of files */ -void LightApp_Study::SetListOfFiles (const char* theModuleName, const std::vector theListOfFiles) +void LightApp_Study::SetListOfFiles (const char* theModuleName, int /*type*/, const std::vector theListOfFiles) { myDriver->SetListOfFiles(theModuleName, theListOfFiles); } @@ -439,7 +440,7 @@ void LightApp_Study::SetListOfFiles (const char* theModuleName, const std::vecto /*! Removes temporary files */ -void LightApp_Study::RemoveTemporaryFiles (const char* theModuleName, const bool isMultiFile) const +void LightApp_Study::RemoveTemporaryFiles (const char* theModuleName, bool isMultiFile, bool /*force*/) { if (isMultiFile) return; diff --git a/src/LightApp/LightApp_Study.h b/src/LightApp/LightApp_Study.h index 750f2c5dd..ea06fc49e 100644 --- a/src/LightApp/LightApp_Study.h +++ b/src/LightApp/LightApp_Study.h @@ -114,16 +114,16 @@ public: virtual LightApp_DataObject* findObjectByEntry( const QString& theEntry ); protected: - virtual void saveModuleData ( QString theModuleName, QStringList theListOfFiles ); - virtual void openModuleData ( QString theModuleName, QStringList& theListOfFiles ); - virtual bool saveStudyData ( const QString& theFileName ); - virtual bool openStudyData ( const QString& theFileName ); + virtual void saveModuleData ( QString theModuleName, int type, QStringList theListOfFiles ); + virtual void openModuleData ( QString theModuleName, int type, QStringList& theListOfFiles ); + virtual bool saveStudyData ( const QString& theFileName, int type ); + virtual bool openStudyData ( const QString& theFileName, int type ); - virtual std::vector GetListOfFiles ( const char* theModuleName ) const; - virtual void SetListOfFiles ( const char* theModuleName, + virtual std::vector GetListOfFiles ( const char* theModuleName, int type ) const; + virtual void SetListOfFiles ( const char* theModuleName, int type, const std::vector theListOfFiles ); - virtual void RemoveTemporaryFiles ( const char* theModuleName, const bool isMultiFile ) const; + virtual void RemoveTemporaryFiles ( const char*, bool, bool = false ); protected: virtual bool openDataModel ( const QString&, CAM_DataModel* ); diff --git a/src/SalomeApp/SalomeApp_Engine_i.cxx b/src/SalomeApp/SalomeApp_Engine_i.cxx index 3ce49b656..ffa142935 100644 --- a/src/SalomeApp/SalomeApp_Engine_i.cxx +++ b/src/SalomeApp/SalomeApp_Engine_i.cxx @@ -48,7 +48,7 @@ Constructor */ SalomeApp_Engine_i::SalomeApp_Engine_i( const char* theComponentName ) - : myComponentName( theComponentName ) + : myKeepFiles( false ), myComponentName( theComponentName ) { MESSAGE("SalomeApp_Engine_i::SalomeApp_Engine_i(): myComponentName = " << qPrintable( myComponentName ) << ", this = " << this); @@ -85,7 +85,8 @@ SALOMEDS::TMPFile* SalomeApp_Engine_i::Save (SALOMEDS::SComponent_ptr theCompone bool manuallySaved = false; - if ( GetListOfFiles().empty() ) { + if ( GetListOfFiles(0).empty() ) // 0 means persistence file + { // Save was probably called from outside GUI, so SetListOfFiles was not called! // Try to get list of files from directly from data model @@ -94,7 +95,7 @@ SALOMEDS::TMPFile* SalomeApp_Engine_i::Save (SALOMEDS::SComponent_ptr theCompone qPrintable( myComponentName ) << "it seems Save() was called from outside GUI" ); - // - Get app rnv + // - Get app SalomeApp_Application* app = dynamic_cast(SUIT_Session::session()->activeApplication()); if ( !app ) @@ -125,7 +126,7 @@ SALOMEDS::TMPFile* SalomeApp_Engine_i::Save (SALOMEDS::SComponent_ptr theCompone if ( !name.isEmpty() ) names.push_back(name.toUtf8().data()); } - SetListOfFiles( names ); + SetListOfFiles( 0, names ); // 0 means persistence file manuallySaved = true; } @@ -134,26 +135,30 @@ SALOMEDS::TMPFile* SalomeApp_Engine_i::Save (SALOMEDS::SComponent_ptr theCompone // listOfFiles must contain temporary directory name in its first item // and names of files (relatively the temporary directory) in the others - const int n = myListOfFiles.size() - 1; + ListOfFiles listOfFiles = GetListOfFiles( 0 ); // 0 means persistence file + const int n = listOfFiles.size() - 1; if (n > 0) { // there are some files, containing persistent data of the component - std::string aTmpDir = myListOfFiles[0]; + std::string aTmpDir = listOfFiles[0]; // Create a list to store names of created files ListOfFiles aSeq; aSeq.reserve(n); for (int i = 0; i < n; i++) - aSeq.push_back(CORBA::string_dup(myListOfFiles[i + 1].c_str())); + aSeq.push_back(CORBA::string_dup(listOfFiles[i + 1].c_str())); // Convert a file to the byte stream 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, true); + SalomeApp_Application* app = + dynamic_cast( SUIT_Session::session()->activeApplication() ); + SalomeApp_Study* study = dynamic_cast( app->activeStudy() ); + study->RemoveTemporaryFiles( myComponentName.toStdString().c_str(), isMultiFile ); } if ( manuallySaved ) - SetListOfFiles( ListOfFiles()); + SetListOfFiles(0, ListOfFiles()); // 0 means persistence file return aStreamFile._retn(); } @@ -188,19 +193,20 @@ CORBA::Boolean SalomeApp_Engine_i::Load (SALOMEDS::SComponent_ptr theComponent, for (int i = 1; i < n; i++) listOfFiles[i] = std::string(aSeq[i - 1]); - SetListOfFiles(listOfFiles); + SetListOfFiles(0, listOfFiles); // 0 means persistence file + keepFiles( true ); return true; } -SalomeApp_Engine_i::ListOfFiles SalomeApp_Engine_i::GetListOfFiles() +SalomeApp_Engine_i::ListOfFiles SalomeApp_Engine_i::GetListOfFiles(int type) { - return myListOfFiles; + return myListOfFiles.count(type) ? myListOfFiles[type] : ListOfFiles(); } -void SalomeApp_Engine_i::SetListOfFiles (const ListOfFiles& theListOfFiles) +void SalomeApp_Engine_i::SetListOfFiles (int type, const ListOfFiles& theListOfFiles) { - myListOfFiles = theListOfFiles; + myListOfFiles[type] = theListOfFiles; } /*! @@ -222,13 +228,15 @@ Engines::TMPFile* SalomeApp_Engine_i::DumpPython(CORBA::Boolean isPublished, aStreamFile[0] = '\0'; isValidScript = true; + ListOfFiles listOfFiles = GetListOfFiles( 1 ); // 1 means dump file + // listOfFiles must contain temporary directory name in its first item // and names of files (relatively the temporary directory) in the others - if ( myListOfFiles.size() < 2 ) + if ( listOfFiles.size() < 2 ) return aStreamFile._retn(); // there are some files, containing persistent data of the component - QString aTmpPath( myListOfFiles.front().c_str() ); + QString aTmpPath( listOfFiles.front().c_str() ); QDir aTmpDir( aTmpPath ); if ( !aTmpDir.exists() ) return aStreamFile._retn(); @@ -237,8 +245,8 @@ Engines::TMPFile* SalomeApp_Engine_i::DumpPython(CORBA::Boolean isPublished, QStringList aFilePaths; QList aFileSizes; qint64 aBuffSize = 0; - ListOfFiles::const_iterator aFIt = myListOfFiles.begin(); - ListOfFiles::const_iterator aFEnd = myListOfFiles.end(); + ListOfFiles::const_iterator aFIt = listOfFiles.begin(); + ListOfFiles::const_iterator aFEnd = listOfFiles.end(); aFIt++; for (; aFIt != aFEnd; aFIt++){ QString aFileName( (*aFIt).c_str() ); diff --git a/src/SalomeApp/SalomeApp_Engine_i.h b/src/SalomeApp/SalomeApp_Engine_i.h index 0adf57777..78f228563 100644 --- a/src/SalomeApp/SalomeApp_Engine_i.h +++ b/src/SalomeApp/SalomeApp_Engine_i.h @@ -62,9 +62,10 @@ public: public: typedef std::vector ListOfFiles; + typedef std::map MapOfFiles; - ListOfFiles GetListOfFiles (); - void SetListOfFiles (const ListOfFiles& theListOfFiles); + ListOfFiles GetListOfFiles (int); + void SetListOfFiles (int, const ListOfFiles& theListOfFiles); static std::string EngineIORForComponent( const char* theComponentName, bool toCreate ); @@ -90,6 +91,9 @@ public: CORBA::Boolean CanPaste( const char*, CORBA::Long ) {return 0;} SALOMEDS::SObject_ptr PasteInto( const SALOMEDS::TMPFile&, CORBA::Long, SALOMEDS::SObject_ptr ) {return 0;} + bool keepFiles() const { return myKeepFiles; } + void keepFiles( bool keep ) { myKeepFiles = keep; } + char* getVersion(); private: @@ -97,7 +101,8 @@ private: static PortableServer::POA_var poa(); static SALOME_NamingService* namingService(); private: - ListOfFiles myListOfFiles; + MapOfFiles myListOfFiles; + bool myKeepFiles; QString myComponentName; }; diff --git a/src/SalomeApp/SalomeApp_Study.cxx b/src/SalomeApp/SalomeApp_Study.cxx index 3bc828a45..e3ffd5930 100644 --- a/src/SalomeApp/SalomeApp_Study.cxx +++ b/src/SalomeApp/SalomeApp_Study.cxx @@ -624,7 +624,8 @@ bool SalomeApp_Study::saveDocumentAs( const QString& theFileName ) listOfFiles.clear(); aModel->saveAs( theFileName, this, listOfFiles ); if ( !listOfFiles.isEmpty() ) - saveModuleData(aModel->module()->name(), listOfFiles); + saveModuleData(aModel->module()->name(), 0, // 0 means persistence file + listOfFiles); } } @@ -638,7 +639,7 @@ bool SalomeApp_Study::saveDocumentAs( const QString& theFileName ) bool res = studyDS()->SaveAs( theFileName.toUtf8().data(), isMultiFile, isAscii ) && CAM_Study::saveDocumentAs( theFileName ); - res = res && saveStudyData(theFileName); + res = res && saveStudyData(theFileName, 0); // 0 means persistence file if ( res ) emit saved( this ); @@ -667,7 +668,8 @@ bool SalomeApp_Study::saveDocument() listOfFiles.clear(); aModel->save(listOfFiles); if ( !listOfFiles.isEmpty() ) - saveModuleData(aModel->module()->name(), listOfFiles); + saveModuleData(aModel->module()->name(), 0, // 0 means persistence file + listOfFiles); } } @@ -680,7 +682,7 @@ bool SalomeApp_Study::saveDocument() bool isAscii = resMgr->booleanValue( "Study", "ascii_file", false ); bool res = studyDS()->Save( isMultiFile, isAscii ) && CAM_Study::saveDocument(); - res = res && saveStudyData(studyName()); + res = res && saveStudyData(studyName(), 0); // 0 means persistence file if ( res ) emit saved( this ); @@ -761,7 +763,8 @@ bool SalomeApp_Study::dump( const QString& theFileName, // This call simply passes the data model's dump output to SalomeApp_Engine servant. // This code is shared with persistence mechanism. // NOTE: this should be revised if behavior of saveModuleData() changes! - saveModuleData(aModel->module()->name(), listOfFiles); + saveModuleData(aModel->module()->name(), 1, // 1 means dump file + listOfFiles); } } @@ -778,7 +781,7 @@ bool SalomeApp_Study::dump( const QString& theFileName, // Issue 21377 - Clean up light module data in SalomeApp_Engine servant // This code is shared with persistence mechanism. // NOTE: this should be revised if behavior of saveStudyData() changes! - saveStudyData( theFileName ); + saveStudyData( theFileName, 1 ); // 0 means persistence file return res; } @@ -821,7 +824,7 @@ bool SalomeApp_Study::isSaved() const \param theModuleName - name of module \param theListOfFiles - list of files to be saved */ -void SalomeApp_Study::saveModuleData( QString theModuleName, QStringList theListOfFiles ) +void SalomeApp_Study::saveModuleData( QString theModuleName, int type, QStringList theListOfFiles ) { int aNb = theListOfFiles.count(); if ( aNb == 0 ) @@ -835,7 +838,7 @@ void SalomeApp_Study::saveModuleData( QString theModuleName, QStringList theList aListOfFiles[anIndex] = (*it).toUtf8().data(); anIndex++; } - SetListOfFiles(theModuleName.toStdString().c_str(), aListOfFiles); + SetListOfFiles(theModuleName.toStdString().c_str(), type, aListOfFiles); } /*! @@ -843,9 +846,9 @@ void SalomeApp_Study::saveModuleData( QString theModuleName, QStringList theList \param theModuleName - name of module \param theListOfFiles - list of files to be loaded */ -void SalomeApp_Study::openModuleData( QString theModuleName, QStringList& theListOfFiles ) +void SalomeApp_Study::openModuleData( QString theModuleName, int type, QStringList& theListOfFiles ) { - std::vector aListOfFiles = GetListOfFiles( theModuleName.toStdString().c_str() ); + std::vector aListOfFiles = GetListOfFiles( theModuleName.toStdString().c_str(), type ); int i, aLength = aListOfFiles.size() - 1; if ( aLength < 0 ) @@ -862,18 +865,17 @@ void SalomeApp_Study::openModuleData( QString theModuleName, QStringList& theLis Re-implemented from LightApp_Study, actually does not save anything but simply cleans up light modules' data */ -bool SalomeApp_Study::saveStudyData( const QString& theFileName ) +bool SalomeApp_Study::saveStudyData( const QString& theFileName, int type ) { ModelList list; dataModels( list ); QListIterator it( list ); - std::vector listOfFiles(0); while ( it.hasNext() ){ LightApp_DataModel* aLModel = dynamic_cast( it.next() ); // It is safe to call SetListOfFiles() for any kind of module // because SetListOfFiles() does nothing for full modules :) if ( aLModel ) - SetListOfFiles(aLModel->module()->name().toStdString().c_str(), listOfFiles); + SetListOfFiles(aLModel->module()->name().toStdString().c_str(), type, std::vector()); } return true; } @@ -881,9 +883,9 @@ bool SalomeApp_Study::saveStudyData( const QString& theFileName ) /*! Loads data for study */ -bool SalomeApp_Study::openStudyData( const QString& theFileName ) +bool SalomeApp_Study::openStudyData( const QString& /*theFileName*/, int /*type*/ ) { - return true; + return true; } /*! @@ -1039,14 +1041,15 @@ bool SalomeApp_Study::openDataModel( const QString& studyName, CAM_DataModel* dm // for a given component in the study yet } QStringList listOfFiles; - openModuleData(dm->module()->name(), listOfFiles); + openModuleData(dm->module()->name(), 0, // 0 means persistence file + listOfFiles); if (dm && dm->open(studyName, this, listOfFiles)) { // Remove the files and temporary directory, created // for this module by LightApp_Engine_i::Load() bool isMultiFile = false; // TODO: decide, how to access this parameter - RemoveTemporaryFiles( dm->module()->name().toStdString().c_str(), isMultiFile ); - std::vector listOfFiles ; - SetListOfFiles( dm->module()->name().toStdString().c_str(), listOfFiles ); + RemoveTemporaryFiles( dm->module()->name().toStdString().c_str(), isMultiFile, true ); + SetListOfFiles( dm->module()->name().toStdString().c_str(), 0, // 0 means persistence file + std::vector() ); // Something has been read -> create data model tree LightApp_DataModel* aDM = dynamic_cast( dm ); @@ -1064,15 +1067,14 @@ bool SalomeApp_Study::openDataModel( const QString& studyName, CAM_DataModel* dm \return list of files used by module: to be used by CORBAless modules \param theModuleName - name of module */ -std::vector SalomeApp_Study::GetListOfFiles( const char* theModuleName ) const +std::vector SalomeApp_Study::GetListOfFiles( const char* theModuleName, int type ) const { // Issue 21377 - using separate engine for each type of light module SalomeApp_Engine_i* aDefaultEngine = SalomeApp_Engine_i::GetInstance( theModuleName, false ); if (aDefaultEngine) - return aDefaultEngine->GetListOfFiles(); + return aDefaultEngine->GetListOfFiles( type ); - std::vector aListOfFiles; - return aListOfFiles; + return std::vector(); } /*! @@ -1083,13 +1085,13 @@ std::vector SalomeApp_Study::GetListOfFiles( const char* theModuleN \param theModuleName - name of module \param theListOfFiles - list of files */ -void SalomeApp_Study::SetListOfFiles ( const char* theModuleName, +void SalomeApp_Study::SetListOfFiles ( const char* theModuleName, int type, const std::vector theListOfFiles ) { // Issue 21377 - using separate engine for each type of light module SalomeApp_Engine_i* aDefaultEngine = SalomeApp_Engine_i::GetInstance( theModuleName, false ); if (aDefaultEngine) - aDefaultEngine->SetListOfFiles(theListOfFiles); + aDefaultEngine->SetListOfFiles(type, theListOfFiles); } /*! @@ -1105,12 +1107,12 @@ std::string SalomeApp_Study::GetTmpDir ( const char* theURL, const bool isMulti /*! Removes temporary files */ -void SalomeApp_Study::RemoveTemporaryFiles ( const char* theModuleName, const bool isMultiFile ) const +void SalomeApp_Study::RemoveTemporaryFiles ( const char* theModuleName, bool isMultiFile, bool force ) { if (isMultiFile) return; - SALOMEDS_Tool::ListOfFiles aListOfFiles = GetListOfFiles( theModuleName ); + SALOMEDS_Tool::ListOfFiles aListOfFiles = GetListOfFiles( theModuleName, 0 ); if (aListOfFiles.size() > 0) { std::string aTmpDir = aListOfFiles[0]; @@ -1120,7 +1122,13 @@ void SalomeApp_Study::RemoveTemporaryFiles ( const char* theModuleName, const bo for (int i = 0; i < n; i++) aSeq.push_back(CORBA::string_dup(aListOfFiles[i + 1].c_str())); - SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aSeq, true); + SalomeApp_Engine_i* engine = SalomeApp_Engine_i::GetInstance( theModuleName, false ); + bool toRemove = force || engine && !engine->keepFiles(); + + if ( toRemove ) { + SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aSeq, true); + engine->keepFiles( false ); + } } } diff --git a/src/SalomeApp/SalomeApp_Study.h b/src/SalomeApp/SalomeApp_Study.h index 18573c745..466e461ba 100644 --- a/src/SalomeApp/SalomeApp_Study.h +++ b/src/SalomeApp/SalomeApp_Study.h @@ -88,16 +88,17 @@ public: virtual LightApp_DataObject* findObjectByEntry( const QString& theEntry ); + virtual void RemoveTemporaryFiles ( const char*, bool, bool = false ); + protected: - virtual void saveModuleData ( QString theModuleName, QStringList theListOfFiles ); - virtual void openModuleData ( QString theModuleName, QStringList& theListOfFiles ); - virtual bool saveStudyData ( const QString& theFileName ); - virtual bool openStudyData ( const QString& theFileName ); + virtual void saveModuleData ( QString theModuleName, int type, QStringList theListOfFiles ); + virtual void openModuleData ( QString theModuleName, int type, QStringList& theListOfFiles ); + virtual bool saveStudyData ( const QString& theFileName, int type ); + virtual bool openStudyData ( const QString& theFileName, int type ); - virtual std::vector GetListOfFiles ( const char* theModuleName ) const; - virtual void SetListOfFiles ( const char* theModuleName, + virtual std::vector GetListOfFiles ( const char* theModuleName, int type ) const; + virtual void SetListOfFiles ( const char* theModuleName, int type, const std::vector theListOfFiles); - virtual void RemoveTemporaryFiles ( const char* theModuleName, const bool isMultiFile) const; protected: virtual void dataModelInserted( const CAM_DataModel* ); -- 2.39.2