MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / runProcess

Method runProcess

tools/triage/mainwindow.cpp:218–260  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216}
217
218bool MainWindow::runProcess(const QString &programName, const QStringList &arguments)
219{
220 QProgressDialog dialog("Running external process: " + programName, "Kill", 0 /*min*/, 1 /*max*/, this);
221 dialog.setWindowModality(Qt::WindowModal);
222 dialog.setMinimumDuration(0 /*msec*/);
223 dialog.setValue(0);
224
225 QProcess process;
226 process.setWorkingDirectory(WORK_FOLDER);
227 process.start(programName, arguments); // async action
228
229 bool success = false;
230 bool state = (QProcess::Running == process.state() || QProcess::Starting == process.state());
231 while (!success && state) {
232 success = process.waitForFinished(50 /*msec*/);
233 // Not the best way to keep UI unfreeze, keep work async in other thread much more a Qt style
234 QCoreApplication::processEvents();
235 if (dialog.wasCanceled()) {
236 process.kill();
237 success = false;
238 break;
239 }
240 state = (QProcess::Running == process.state() || QProcess::Starting == process.state());
241 }
242 dialog.setValue(1);
243 if (!success) {
244 QString errorstr(programName);
245 errorstr.append(": ");
246 errorstr.append(process.errorString());
247 ui->statusBar->showMessage(errorstr);
248 } else {
249 const int exitCode = process.exitCode();
250 if (exitCode != 0) {
251 success = false;
252 const QByteArray stderrOutput = process.readAllStandardError();
253 QString errorstr(programName);
254 errorstr.append(QString(": exited with %1: ").arg(exitCode));
255 errorstr.append(stderrOutput);
256 ui->statusBar->showMessage(errorstr);
257 }
258 }
259 return success;
260}
261
262bool MainWindow::wget(const QString &url)
263{

Callers

nothing calls this directly

Calls 2

QStringClass · 0.50
setValueMethod · 0.45

Tested by

no test coverage detected