+ 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
+
+ MESSAGE("SalomeApp_Engine_i::Save(): myComponentName = " <<
+ qPrintable( myComponentName ) <<
+ "it seems Save() was called from outside GUI" );
+
+ // - Get app
+ SalomeApp_Application* app =
+ dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
+ if ( !app )
+ return aStreamFile._retn();
+
+ // - Get study
+ SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
+
+ if ( !study )
+ return aStreamFile._retn();
+ QString url = QString::fromStdString(study->studyDS()->URL());
+
+ // - 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( 0, names ); // 0 means persistence file
+ manuallySaved = true;
+ }
+
+ // Get a temporary directory to store a file
+ //std::string aTmpDir = isMultiFile ? theURL : SALOMEDS_Tool::GetTmpDir();