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
|
else
|
||||||
m_process->setCommand({"sh", {}});
|
m_process->setCommand({"sh", {}});
|
||||||
|
|
||||||
connect(m_process.get(), &QtcProcess::finished,
|
connect(m_process.get(), &QtcProcess::done, this, &PerfTracePointDialog::handleProcessDone);
|
||||||
this, &PerfTracePointDialog::handleProcessFinished);
|
|
||||||
|
|
||||||
connect(m_process.get(), &QtcProcess::errorOccurred,
|
|
||||||
this, &PerfTracePointDialog::handleProcessError);
|
|
||||||
|
|
||||||
m_process->start();
|
m_process->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PerfTracePointDialog::handleProcessFinished()
|
void PerfTracePointDialog::handleProcessDone()
|
||||||
{
|
{
|
||||||
if (m_process->exitCode() != 0) {
|
const QProcess::ProcessError error = m_process->error();
|
||||||
m_ui->label->setText(tr("Failed to create trace points."));
|
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 {
|
} else {
|
||||||
m_ui->label->setText(tr("Created trace points for: %1")
|
message = tr("Created trace points for: %1").arg(QString::fromUtf8(
|
||||||
.arg(QString::fromUtf8(
|
m_process->readAllStandardOutput().trimmed().replace('\n', ", ")));
|
||||||
m_process->readAllStandardOutput().trimmed()
|
|
||||||
.replace('\n', ", "))));
|
|
||||||
}
|
}
|
||||||
|
m_ui->label->setText(message);
|
||||||
m_ui->textEdit->setHtml(QString::fromUtf8(m_process->readAllStandardError()));
|
m_ui->textEdit->setHtml(QString::fromUtf8(m_process->readAllStandardError()));
|
||||||
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
||||||
m_ui->buttonBox->button(QDialogButtonBox::Cancel)->setEnabled(false);
|
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()
|
void PerfTracePointDialog::accept()
|
||||||
{
|
{
|
||||||
if (m_process) {
|
if (m_process) {
|
||||||
|
@@ -47,8 +47,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void runScript();
|
void runScript();
|
||||||
void handleProcessFinished();
|
void handleProcessDone();
|
||||||
void handleProcessError(QProcess::ProcessError error);
|
|
||||||
void finish();
|
void finish();
|
||||||
|
|
||||||
Ui::PerfTracePointDialog *m_ui;
|
Ui::PerfTracePointDialog *m_ui;
|
||||||
|
Reference in New Issue
Block a user