forked from qt-creator/qt-creator
PerfTracePointDialog: Connect to QtcProcess::done() signal
Instead of connecting to errorOccurred() and finished() signals. Change-Id: I82d9a2fbd583a6b1ffce2083369f683c9a208c18 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -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) {
|
||||
|
@@ -47,8 +47,7 @@ public:
|
||||
|
||||
private:
|
||||
void runScript();
|
||||
void handleProcessFinished();
|
||||
void handleProcessError(QProcess::ProcessError error);
|
||||
void handleProcessDone();
|
||||
void finish();
|
||||
|
||||
Ui::PerfTracePointDialog *m_ui;
|
||||
|
Reference in New Issue
Block a user