code-google-com / qdevelop

Automatically exported from code.google.com/p/qdevelop
GNU General Public License v2.0
1 stars 1 forks source link

Program arguments not managed correctly #294

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When adding command line arguments to a program (debug - parameters) they
work correctly during debug but not under release. When the program is run
under release the arguments are considered as a single arguments, rather
than being separated into switches and arguments.

This causes a problem when a file name is passed in quotes as an argument
(because it has a space in the file name it requires to be wrapped in quotes).

FIX
changes are required to void Debug::executeWithoutDebug() in debug.cpp
CODE CHANGE
void Debug::executeWithoutDebug()
{
    emit message( tr("Running...") );
    processDebug = new QProcess();
    connect(processDebug, SIGNAL(readyReadStandardOutput()), this,
SLOT(slotMessagesDebug()) );
    connect(processDebug, SIGNAL(readyReadStandardError()), this,
SLOT(slotMessagesDebug()) );

    setEnvironment( processDebug );

    //processDebug->start("\""+executableName+"\"",  QStringList() <<
m_parameters.arguments);
   // Graeme: Parameters need to be properly parsed
   QStringList argList = QStringList();
   QString args = m_parameters.arguments;
   bool openBracket = false;
   int ele = 0;
   argList.insert(ele, QString());
   for (int i = 0; i < args.size(); ++i)
   {
      if (args.at(i) == '"')
         openBracket = !openBracket;
      if (!openBracket && args.at(i).isSpace())
      {
         if (!argList.last().isEmpty())
         {
            argList.insert(++ele, QString());   // move to the next element
in the list
         }
         continue;   // avoid adding the spaces in the list
      }
      argList[ele].append(args.at(i));
   }
    processDebug->start(executableName,  argList);
   // Graeme: End parameters have now been parsed
   processDebug->waitForFinished(500); // On attend un peu pour passer en
�at Running
    while( processDebug->state() == QProcess::Running )
    {
        processDebug->waitForFinished(5);
    }
    emit message( "---------------------- "+tr("Exited normally")+"
----------------------" );
    emit endDebug();
}

END CODE CHANGE
one line removed, block of code added with identifying comment around it.
I've tested it and it meets my needs.
END FIX

Original issue reported on code.google.com by foster.g...@gmail.com on 30 Jun 2008 at 11:27

GoogleCodeExporter commented 9 years ago
Slight modification required...

   int ele = 0;
   if (args.size()>0)
      argList.insert(0,QString());
   for (int i = 0; i < args.size(); ++i)

wrapping the if around insert:

    //processDebug->start("\""+executableName+"\"",  QStringList() <<
m_parameters.arguments);
   // Graeme: Parameters need to be properly parsed
   QStringList argList = QStringList();
   QString args = m_parameters.arguments;
   bool openBracket = false;
   int ele = 0;
   if (args.size()>0)
      argList.insert(0,QString());
   for (int i = 0; i < args.size(); ++i)
   {
      if (args.at(i) == '"')
         openBracket = !openBracket;
      if (!openBracket && args.at(i).isSpace())
      {
         if (!argList.last().isEmpty())
         {
            argList.insert(++ele, QString());   // move to the next element in the list
         }
         continue;   // avoid adding the spaces in the list
      }
      argList[ele].append(args.at(i));
   }
    processDebug->start(executableName,  argList);
   // Graeme: End parameters have now been parsed
   processDebug->waitForFinished(500); // On attend un peu pour passer en �at Running

Original comment by foster.g...@gmail.com on 12 Jul 2008 at 2:20

GoogleCodeExporter commented 9 years ago
Fixed in r366

Original comment by Lord.Div...@gmail.com on 30 Jan 2009 at 8:43