From 2de666da613fbc5f75d5133bae9efabca0cb4b77 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Thu, 6 Nov 2014 12:30:39 +0100 Subject: [PATCH] Vcs: Report stderr messages in checkout wizard Do not delay them till after the command has finished. Change-Id: I52984e1deeaeb33e3feba0a5b6b982059870f4b8 Reviewed-by: Orgad Shaneh --- .../vcsbase/checkoutprogresswizardpage.cpp | 57 ++++++++++--------- .../vcsbase/checkoutprogresswizardpage.h | 5 +- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/plugins/vcsbase/checkoutprogresswizardpage.cpp b/src/plugins/vcsbase/checkoutprogresswizardpage.cpp index 1f396c96376..62adb1f6423 100644 --- a/src/plugins/vcsbase/checkoutprogresswizardpage.cpp +++ b/src/plugins/vcsbase/checkoutprogresswizardpage.cpp @@ -76,8 +76,7 @@ CheckoutProgressWizardPage::CheckoutProgressWizardPage(QWidget *parent) : CheckoutProgressWizardPage::~CheckoutProgressWizardPage() { - if (m_state == Running) // Paranoia! - QApplication::restoreOverrideCursor(); + QTC_ASSERT(m_state != Running, QApplication::restoreOverrideCursor()); delete m_formatter; } @@ -96,8 +95,9 @@ void CheckoutProgressWizardPage::start(VcsCommand *command) QTC_ASSERT(m_state != Running, return); m_command = command; command->setProgressiveOutput(true); - connect(command, SIGNAL(output(QString)), this, SLOT(slotOutput(QString))); - connect(command, SIGNAL(finished(bool,int,QVariant)), this, SLOT(slotFinished(bool,int,QVariant))); + connect(command, &VcsCommand::output, this, &CheckoutProgressWizardPage::reportStdOut); + connect(command, &VcsCommand::errorText, this, &CheckoutProgressWizardPage::reportStdErr); + connect(command, &VcsCommand::finished, this, &CheckoutProgressWizardPage::slotFinished); QApplication::setOverrideCursor(Qt::WaitCursor); m_logPlainTextEdit->clear(); m_overwriteOutput = false; @@ -109,39 +109,40 @@ void CheckoutProgressWizardPage::start(VcsCommand *command) void CheckoutProgressWizardPage::slotFinished(bool ok, int exitCode, const QVariant &) { - if (ok && exitCode == 0) { - if (m_state == Running) { - m_state = Succeeded; - QApplication::restoreOverrideCursor(); - m_statusLabel->setText(tr("Succeeded.")); - QPalette palette; - palette.setColor(QPalette::Active, QPalette::Text, Qt::green); - m_statusLabel->setPalette(palette); - emit completeChanged(); - emit terminated(true); - } + QTC_ASSERT(m_state == Running, return); + + const bool success = (ok && exitCode == 0); + QString message; + QPalette palette; + + if (success) { + m_state = Succeeded; + message = tr("Succeeded."); + palette.setColor(QPalette::Active, QPalette::Text, Qt::green); } else { - m_logPlainTextEdit->appendPlainText(m_error); - if (m_state == Running) { - m_state = Failed; - QApplication::restoreOverrideCursor(); - m_statusLabel->setText(tr("Failed.")); - QPalette palette; - palette.setColor(QPalette::Active, QPalette::Text, Qt::red); - m_statusLabel->setPalette(palette); - emit terminated(false); - } + m_state = Failed; + message = tr("Failed."); + palette.setColor(QPalette::Active, QPalette::Text, Qt::red); } + + m_statusLabel->setText(message); + m_statusLabel->setPalette(palette); + + QApplication::restoreOverrideCursor(); + + if (success) + emit completeChanged(); + emit terminated(success); } -void CheckoutProgressWizardPage::slotOutput(const QString &text) +void CheckoutProgressWizardPage::reportStdOut(const QString &text) { m_formatter->appendMessage(text, Utils::StdOutFormat); } -void CheckoutProgressWizardPage::slotError(const QString &text) +void CheckoutProgressWizardPage::reportStdErr(const QString &text) { - m_error.append(text); + m_formatter->appendMessage(text, Utils::StdErrFormat); } void CheckoutProgressWizardPage::terminate() diff --git a/src/plugins/vcsbase/checkoutprogresswizardpage.h b/src/plugins/vcsbase/checkoutprogresswizardpage.h index b8e572c4e74..a1fb94085f9 100644 --- a/src/plugins/vcsbase/checkoutprogresswizardpage.h +++ b/src/plugins/vcsbase/checkoutprogresswizardpage.h @@ -69,8 +69,8 @@ signals: private slots: void slotFinished(bool ok, int exitCode, const QVariant &cookie); - void slotOutput(const QString &text); - void slotError(const QString &text); + void reportStdOut(const QString &text); + void reportStdErr(const QString &text); private: QPlainTextEdit *m_logPlainTextEdit; @@ -79,7 +79,6 @@ private: VcsCommand *m_command; QString m_startedStatus; - QString m_error; bool m_overwriteOutput; State m_state;