Salome HOME
Merge changes from 'master' branch.
authorrnv <rnv@opencascade.com>
Mon, 25 Dec 2017 15:51:30 +0000 (18:51 +0300)
committerrnv <rnv@opencascade.com>
Fri, 29 Dec 2017 13:33:47 +0000 (16:33 +0300)
12 files changed:
1  2 
CMakeLists.txt
SalomeGUIConfig.cmake.in
bin/gui_setenv.py
src/LightApp/LightApp_Application.cxx
src/LightApp/LightApp_Application.h
src/LightApp/resources/LightApp_msg_fr.ts
src/LightApp/resources/LightApp_msg_ja.ts
src/SALOME_SWIG/SALOMEGUI_Swig.cxx
src/SalomeApp/SalomeApp_Engine_i.cxx
src/SalomeApp/SalomeApp_Engine_i.h
src/SalomeApp/SalomeApp_Study.cxx
src/Session/SALOME_Session_Server.cxx

diff --cc CMakeLists.txt
Simple merge
Simple merge
Simple merge
Simple merge
index cc6ce1ea87aa0f2fa02d4a4015bbe6f04cd04339,cd9ce2e159e5633b75975d48701bdb29235e60e6..eaef8331edbf60d1818ab2e9d697d5b196ed8209
@@@ -339,7 -341,10 +339,9 @@@ protected
  
    static LightApp_Preferences*        _prefs_;
  
 -  static int                          lastStudyId;
    QStringList                         myUserWmTypes;
+   friend void LightAppCleanUpAppResources();
  };
  
  #ifdef WIN32
Simple merge
index 108cee699ef84f9262bb889604f18a1f77a5694f,4c85ff6c7c90b7712bf36bf10fd2d7213084b9ca..594ed26892c219c9dc39990ef44b81e640b19da4
@@@ -65,38 -85,89 +69,91 @@@ SALOMEDS::TMPFile* SalomeApp_Engine_i::
  {
    SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile;
  
 -  if ( CORBA::is_nil(theComponent) || CORBA::is_nil( theComponent->GetStudy() ) )
 -    return aStreamFile._retn();
 +  if (CORBA::is_nil(theComponent))
 +    return aStreamFile._retn();
++  
+   // Component type
 -  QString componentName = theComponent->ComponentDataType();
++  QString componentName (theComponent->ComponentDataType());
 +
+   // Error somewhere outside - Save() called with wrong SComponent instance
+   if ( myComponentName != componentName )
+     return aStreamFile._retn();
 -
 -  // Get study ID
 -  const int studyId = theComponent->GetStudy()->StudyId();
++    
 +  // Get a temporary directory to store a file
 +  //std::string aTmpDir = isMultiFile ? theURL : SALOMEDS_Tool::GetTmpDir();
  
-   std::string componentName (theComponent->ComponentDataType());
+   bool manuallySaved = false;
  
-   // Error somewhere outside - Save() called with
-   // wrong SComponent instance
-   if ( myComponentName != componentName )
-     return aStreamFile._retn();
 -  if ( !myMap.count( studyId ) ) {
++  if ( GetListOfFiles().empty() ) {
++
+     // Save was probably called from outside GUI, so SetListOfFiles was not called!
+     // Try to get list of files from directly from data model
+     MESSAGE("SalomeApp_Engine_i::Save(): myComponentName = " <<
+             qPrintable( myComponentName ) <<
+             "it seems Save() was called from outside GUI" );
++    // - Get app rnv
++    SalomeApp_Application* app = 
++      dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
++    if ( !app )
++      return aStreamFile._retn();
++
+     // - Get study
 -    SalomeApp_Study* study = getStudyById( studyId );
++    SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
++
+     if ( !study )
+       return aStreamFile._retn();
+     QString url = QString::fromStdString(study->studyDS()->URL());
 -    // - Get app
 -    SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( study->application() );
 -    if ( !app )
 -      return aStreamFile._retn();
++
+     // - Get module
+     CAM_Module* module = app->module( SalomeApp_Application::moduleTitle( componentName ) );
+     if ( !module ) // load module???
+       return aStreamFile._retn();
+     // - Get data model
+     LightApp_DataModel* dataModel = dynamic_cast<LightApp_DataModel*>( module->dataModel() );
+     if ( !dataModel )
+       return aStreamFile._retn();
+     // - Save data files
+     QStringList dataFiles;
+     // we use 'url' instead of 'theURL' as latter normally contains path to the tmp dir,
+     // but not actual study's URL
+     dataModel->saveAs( url, study, dataFiles );
+     std::vector<std::string> names;
+     foreach ( QString name, dataFiles ) {
+       if ( !name.isEmpty() )
+         names.push_back(name.toUtf8().data());
+     }
 -    SetListOfFiles( names, studyId );
++    SetListOfFiles( names );
+     manuallySaved = true;
+   }
+   // Get a temporary directory to store a file
+   //std::string aTmpDir = isMultiFile ? theURL : SALOMEDS_Tool::GetTmpDir();
  
 -  if ( myMap.count( studyId ) ) {
 -
 -    const ListOfFiles& listOfFiles = myMap[studyId];
 -
 -    // listOfFiles must contain temporary directory name in its first item
 -    // and names of files (relatively the temporary directory) in the others
 -    const int n = listOfFiles.size() - 1;
 -
 -    if (n > 0) { // there are some files, containing persistent data of the component
 -      std::string aTmpDir = listOfFiles[0];
 -
 -      // Create a list to store names of created files
 -      SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames;
 -      aSeq->length(n);
 -      for (int i = 0; i < n; i++)
 -        aSeq[i] = CORBA::string_dup(listOfFiles[i + 1].c_str());
 -
 -      // Convert a file to the byte stream
 -      aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.c_str(), aSeq.in(), isMultiFile);
 -
 -      // Remove the files and tmp directory, created by the component storage procedure
 -      if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aSeq.in(), true);
 -    }
 +  // 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;
++  
 +  if (n > 0) { // there are some files, containing persistent data of the component
 +    std::string aTmpDir = myListOfFiles[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()));
++    
 +    // 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);
    }
 -
++  
+   if ( manuallySaved )
 -    SetListOfFiles( ListOfFiles(), studyId );
++    SetListOfFiles( ListOfFiles());
  
    return aStreamFile._retn();
  }
@@@ -149,12 -233,13 +206,12 @@@ void SalomeApp_Engine_i::SetListOfFile
  /*! 
   *  DumpPython implementation for light modules
   */
 -Engines::TMPFile* SalomeApp_Engine_i::DumpPython(CORBA::Object_ptr theStudy, 
 -                                               CORBA::Boolean isPublished, 
 -                                               CORBA::Boolean isMultiFile, 
 -                                               CORBA::Boolean& isValidScript)
 +Engines::TMPFile* SalomeApp_Engine_i::DumpPython(CORBA::Boolean isPublished,
 +                                                                       CORBA::Boolean isMultiFile,
 +                                                                       CORBA::Boolean& isValidScript)
  {
    MESSAGE("SalomeApp_Engine_i::DumpPython(): myComponentName = "<<
-         myComponentName << ", this = " << this);
+         qPrintable( myComponentName ) << ", this = " << this);
    
    // Temporary solution: returning a non-empty sequence
    // even if there's nothing to dump, to avoid crashes in SALOMEDS
index 98412512b474d4b69021963bc90e5023fb7e4bbb,d9b3d4b2255ab7d1de77e29b454ff842bde8a692..90a53b9ee12db04e42b02c5fc47d420bc57fee01
@@@ -96,9 -99,10 +97,9 @@@ private
    static PortableServer::POA_var     poa();
    static SALOME_NamingService*       namingService();
  private:
 -  typedef std::map<int, ListOfFiles> MapOfListOfFiles;
 -  MapOfListOfFiles                   myMap;
 +  ListOfFiles                        myListOfFiles;
  
-   std::string                        myComponentName;
+   QString                            myComponentName;
  };
  
  #endif
Simple merge
Simple merge