24 QObject(parent), mName(name), mLastExecutablePath(
"")
26 mProcess =
new QProcess(
this);
29 mProcess->setProcessChannelMode(QProcess::MergedChannels);
30 mProcess->setReadChannel(QProcess::StandardOutput);
37 mProcess->terminate();
43 return mProcess.data();
48 QString absolutePathToExe = this->getExecutableInBundlesAbsolutePath(executable);
50 this->
launch(absolutePathToExe, arguments);
55 if (executable.isEmpty() || this->isRunning())
58 return this->internalLaunch(executable, arguments);
63 return mProcess->state() == QProcess::Running;
68 return mProcess->write(data);
73 return mProcess->waitForStarted(msecs);
78 return mProcess->waitForFinished(msecs);
86 QString ProcessWrapper::getExecutableInBundlesAbsolutePath(QString exeInBundle)
88 QString absolutePathToExe = exeInBundle;
90 if (!QFileInfo(absolutePathToExe).isAbsolute())
93 absolutePathToExe = absolutePathToExe.trimmed();
94 absolutePathToExe = QDir::cleanPath(absolutePathToExe);
96 if (!QFileInfo(absolutePathToExe).exists())
97 reportError(QString(
"Cannot find %1 [%2]").arg(mName).arg(absolutePathToExe));
99 return absolutePathToExe;
102 bool ProcessWrapper::internalLaunch(QString executable, QStringList arguments)
107 report(QString(
"Launching %1: [%2 %3]").arg(mName).arg(executable).arg(arguments.join(
" ")));
109 if(arguments.isEmpty())
110 mProcess->start(executable);
112 mProcess->start(executable, arguments);
114 mLastExecutablePath = executable;