0

I have a problem, this is my code

QProcess *process = new QProcess(this);
process->setEnvironment(QProcess::systemEnvironment());
process->setStandardErrorFile(getAbsolutePath("logs")+"mylog.log",QIODevice::Append);
process->setProgram(program);
process->setArguments(arguments);

//loop is a QEventLoop
loop.connect(process, SIGNAL(finished(int, QProcess::ExitStatus)),
     this, SLOT(finalProcess(int, QProcess::ExitStatus)));

process->start();
qDebug()<<process->program()<<process->arguments();
if(!process->waitForStarted(3600000)) {
    myLog.addMessage(process->program()+" "+process->errorString());
}
loop.exec();
process->close();
delete process;
process = NULL;

This code is a function that is called inside a loop and its works but only n times (for example i need do n = 100 but code crash in n=17) until crash with output (process->errorString())

QProcess failed to start: the file name or extension is too long.

Then I changed the path for other more short, I saw how the n will be more higher before crash, I did more QProcess but not all.

I dont understand why I can't do a number of infinites QProcess if I want, always I wait every one of my QProcess with my QEventLoop to finish. Can anyone have the solution?

thank you very much

Vidya Sagar
  • 1,699
  • 3
  • 17
  • 28
GunHalcon
  • 31
  • 5

1 Answers1

1

Finally i solved my problem, i didnt understand why QProcess output was "the file name or extension is too long.". It was "QProcess::systemEnvironment()" was increasing every time function run. I had a putenv function in another part of my program. Conclusion: "the file name or extension is too long" is because windows can't increase more his path in system environment.

thanks you very much all

GunHalcon
  • 31
  • 5