]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Load on start application HDF file given in command arguments.
authoradv <adv@opencascade.com>
Wed, 30 Nov 2011 13:02:29 +0000 (13:02 +0000)
committeradv <adv@opencascade.com>
Wed, 30 Nov 2011 13:02:29 +0000 (13:02 +0000)
src/SUIT/SUIT_Session.cxx

index 2da346c8c5ecd41cded2c89ed89e1ee2dbd2a4f3..cf1b0e93117f60010b50ec6dceaf768946095572 100755 (executable)
@@ -163,9 +163,41 @@ SUIT_Application* SUIT_Session::startApplication( const QString& name, int /*arg
 
   if ( !myBTimer )
   {
-    myBTimer = (QTimer*)1; // block reation on creation of new application
-    restoreBackup();
-    myBTimer = 0;
+    QString anHDFName;
+    QStringList anArgs = QCoreApplication::arguments();
+    QStringList::const_iterator anArgsIt = anArgs.constBegin();
+    for ( ; anArgsIt != anArgs.constEnd(); anArgsIt++ )
+    {
+      QString anArg = *anArgsIt;
+      QFileInfo aFileInfo( anArg );
+      if ( aFileInfo.exists() && aFileInfo.suffix().toLower() == "hdf" )
+      {
+        anHDFName = anArg;
+        break;
+      }
+    }
+
+    if ( !anHDFName.isEmpty() && app && app->useFile( anHDFName ) )
+    {
+      //Remove backup folders if it exists
+      QDir tmpDir( QDir::tempPath() );
+
+      QString pref = getBPrefix();
+      QFileInfoList aFolders = tmpDir.entryInfoList( QStringList() << QString( pref + "*" ),
+                                                     QDir::Dirs );
+
+      QFileInfoList::const_iterator aFoldersIt = aFolders.constBegin();
+      for ( ; aFoldersIt != aFolders.constEnd(); ++aFoldersIt )
+        Qtx::rmDir( (*aFoldersIt).absoluteFilePath() );
+    }
+    else
+    {
+      //Try to restore backup
+      myBTimer = (QTimer*)1; // block reaction on creation of new application
+      restoreBackup();
+      myBTimer = 0;
+    }
+
     createBTimer();
   }