From: vsr Date: Wed, 18 Jan 2006 12:34:44 +0000 (+0000) Subject: Fix a bug: --modules parameter is not processed correctly if one only module is passe... X-Git-Tag: T_Before_Join_BR-D5-38-2003~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9d25b58bf1c88efb36bae7101eb3b913caf53874;p=modules%2Fgui.git Fix a bug: --modules parameter is not processed correctly if one only module is passed (application goes to infinite loop) --- diff --git a/src/CAM/CAM_Application.cxx b/src/CAM/CAM_Application.cxx index eb7060abd..ef7cd09e4 100755 --- a/src/CAM/CAM_Application.cxx +++ b/src/CAM/CAM_Application.cxx @@ -31,6 +31,7 @@ #include #include #include +#include #ifdef WIN32 #include @@ -428,31 +429,23 @@ void CAM_Application::readModuleList() QStringList modList; - // parse command line arguments - int nbArgs = qApp->argc(); - char** CmdLine = qApp->argv(); - QString CmdStr; - for ( int i = 0; i < nbArgs; i++ ) - { - CmdStr.append(CmdLine[i]); - CmdStr.append(" "); - } - int startId = CmdStr.find("--modules ("); - if ( startId != -1 ) { // application launch with --modules option - startId = CmdStr.find("(", startId); - int stopId = CmdStr.find(" )", startId); - QString ModStr = CmdStr.mid( startId+1, stopId - (startId+1) ).stripWhiteSpace(); - int i = 0; - while ( i < ModStr.length() ) - { - int nextId = ModStr.find( ":", i ); - modList.append( ModStr.mid( i, nextId - i ).stripWhiteSpace() ); - i = nextId + 1; + QStringList args; + for (int i = 1; i < qApp->argc(); i++) + args.append( qApp->argv()[i] ); + + QRegExp rx("--modules\\s+\\(\\s*(.*)\\s*\\)"); + rx.setMinimal( true ); + if ( rx.search( args.join(" ") ) >= 0 && rx.capturedTexts().count() > 0 ) { + QString modules = rx.capturedTexts()[1]; + QStringList mods = QStringList::split(":",modules,false); + for ( uint i = 0; i < mods.count(); i++ ) { + if ( !mods[i].stripWhiteSpace().isEmpty() ) + modList.append( mods[i].stripWhiteSpace() ); } } - else { - QString modStr = resMgr->stringValue( "launch", "modules", QString::null ); - modList = QStringList::split( ",", modStr ); + if ( modList.isEmpty() ) { + QString mods = resMgr->stringValue( "launch", "modules", QString::null ); + modList = QStringList::split( ",", mods ); } for ( QStringList::const_iterator it = modList.begin(); it != modList.end(); ++it )