diff --git a/src/plugins/perfprofiler/perftracepointdialog.cpp b/src/plugins/perfprofiler/perftracepointdialog.cpp index 22d69e0aaa4..3f37a74fe8f 100644 --- a/src/plugins/perfprofiler/perftracepointdialog.cpp +++ b/src/plugins/perfprofiler/perftracepointdialog.cpp @@ -99,40 +99,28 @@ void PerfTracePointDialog::runScript() else m_process->setCommand({"sh", {}}); - connect(m_process.get(), &QtcProcess::finished, - this, &PerfTracePointDialog::handleProcessFinished); - - connect(m_process.get(), &QtcProcess::errorOccurred, - this, &PerfTracePointDialog::handleProcessError); - + connect(m_process.get(), &QtcProcess::done, this, &PerfTracePointDialog::handleProcessDone); m_process->start(); } -void PerfTracePointDialog::handleProcessFinished() +void PerfTracePointDialog::handleProcessDone() { - if (m_process->exitCode() != 0) { - m_ui->label->setText(tr("Failed to create trace points.")); + const QProcess::ProcessError error = m_process->error(); + QString message; + if (error == QProcess::FailedToStart) { + message = tr("Failed to run trace point script: %1").arg(error); + } else if ((m_process->exitStatus() == QProcess::CrashExit) || (m_process->exitCode() != 0)) { + message = tr("Failed to create trace points."); } else { - m_ui->label->setText(tr("Created trace points for: %1") - .arg(QString::fromUtf8( - m_process->readAllStandardOutput().trimmed() - .replace('\n', ", ")))); + message = tr("Created trace points for: %1").arg(QString::fromUtf8( + m_process->readAllStandardOutput().trimmed().replace('\n', ", "))); } + m_ui->label->setText(message); m_ui->textEdit->setHtml(QString::fromUtf8(m_process->readAllStandardError())); m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true); m_ui->buttonBox->button(QDialogButtonBox::Cancel)->setEnabled(false); } -void PerfTracePointDialog::handleProcessError(QProcess::ProcessError error) -{ - if (error == QProcess::FailedToStart) { - m_ui->label->setText(tr("Failed to run trace point script: %1").arg(error)); - m_ui->textEdit->setText(QString::fromUtf8(m_process->readAllStandardError())); - m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true); - m_ui->buttonBox->button(QDialogButtonBox::Cancel)->setEnabled(false); - } -} - void PerfTracePointDialog::accept() { if (m_process) { diff --git a/src/plugins/perfprofiler/perftracepointdialog.h b/src/plugins/perfprofiler/perftracepointdialog.h index 3df2bb18ee2..ce275b8cd34 100644 --- a/src/plugins/perfprofiler/perftracepointdialog.h +++ b/src/plugins/perfprofiler/perftracepointdialog.h @@ -47,8 +47,7 @@ public: private: void runScript(); - void handleProcessFinished(); - void handleProcessError(QProcess::ProcessError error); + void handleProcessDone(); void finish(); Ui::PerfTracePointDialog *m_ui;