From 7ea41bc0b63a9ef9b590b53b5115c62387455afa Mon Sep 17 00:00:00 2001 From: adv Date: Wed, 30 Nov 2011 13:02:29 +0000 Subject: [PATCH] Load on start application HDF file given in command arguments. --- src/SUIT/SUIT_Session.cxx | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/src/SUIT/SUIT_Session.cxx b/src/SUIT/SUIT_Session.cxx index 2da346c8c..cf1b0e931 100755 --- a/src/SUIT/SUIT_Session.cxx +++ b/src/SUIT/SUIT_Session.cxx @@ -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(); } -- 2.39.2