Commit 2de666da authored by Tobias Hunger's avatar Tobias Hunger

Vcs: Report stderr messages in checkout wizard

Do not delay them till after the command has finished.

Change-Id: I52984e1deeaeb33e3feba0a5b6b982059870f4b8
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
parent 66a87a17
...@@ -76,8 +76,7 @@ CheckoutProgressWizardPage::CheckoutProgressWizardPage(QWidget *parent) : ...@@ -76,8 +76,7 @@ CheckoutProgressWizardPage::CheckoutProgressWizardPage(QWidget *parent) :
CheckoutProgressWizardPage::~CheckoutProgressWizardPage() CheckoutProgressWizardPage::~CheckoutProgressWizardPage()
{ {
if (m_state == Running) // Paranoia! QTC_ASSERT(m_state != Running, QApplication::restoreOverrideCursor());
QApplication::restoreOverrideCursor();
delete m_formatter; delete m_formatter;
} }
...@@ -96,8 +95,9 @@ void CheckoutProgressWizardPage::start(VcsCommand *command) ...@@ -96,8 +95,9 @@ void CheckoutProgressWizardPage::start(VcsCommand *command)
QTC_ASSERT(m_state != Running, return); QTC_ASSERT(m_state != Running, return);
m_command = command; m_command = command;
command->setProgressiveOutput(true); command->setProgressiveOutput(true);
connect(command, SIGNAL(output(QString)), this, SLOT(slotOutput(QString))); connect(command, &VcsCommand::output, this, &CheckoutProgressWizardPage::reportStdOut);
connect(command, SIGNAL(finished(bool,int,QVariant)), this, SLOT(slotFinished(bool,int,QVariant))); connect(command, &VcsCommand::errorText, this, &CheckoutProgressWizardPage::reportStdErr);
connect(command, &VcsCommand::finished, this, &CheckoutProgressWizardPage::slotFinished);
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
m_logPlainTextEdit->clear(); m_logPlainTextEdit->clear();
m_overwriteOutput = false; m_overwriteOutput = false;
...@@ -109,39 +109,40 @@ void CheckoutProgressWizardPage::start(VcsCommand *command) ...@@ -109,39 +109,40 @@ void CheckoutProgressWizardPage::start(VcsCommand *command)
void CheckoutProgressWizardPage::slotFinished(bool ok, int exitCode, const QVariant &) void CheckoutProgressWizardPage::slotFinished(bool ok, int exitCode, const QVariant &)
{ {
if (ok && exitCode == 0) { QTC_ASSERT(m_state == Running, return);
if (m_state == Running) {
m_state = Succeeded; const bool success = (ok && exitCode == 0);
QApplication::restoreOverrideCursor(); QString message;
m_statusLabel->setText(tr("Succeeded.")); QPalette palette;
QPalette palette;
palette.setColor(QPalette::Active, QPalette::Text, Qt::green); if (success) {
m_statusLabel->setPalette(palette); m_state = Succeeded;
emit completeChanged(); message = tr("Succeeded.");
emit terminated(true); palette.setColor(QPalette::Active, QPalette::Text, Qt::green);
}
} else { } else {
m_logPlainTextEdit->appendPlainText(m_error); m_state = Failed;
if (m_state == Running) { message = tr("Failed.");
m_state = Failed; palette.setColor(QPalette::Active, QPalette::Text, Qt::red);
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_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); 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() void CheckoutProgressWizardPage::terminate()
......
...@@ -69,8 +69,8 @@ signals: ...@@ -69,8 +69,8 @@ signals:
private slots: private slots:
void slotFinished(bool ok, int exitCode, const QVariant &cookie); void slotFinished(bool ok, int exitCode, const QVariant &cookie);
void slotOutput(const QString &text); void reportStdOut(const QString &text);
void slotError(const QString &text); void reportStdErr(const QString &text);
private: private:
QPlainTextEdit *m_logPlainTextEdit; QPlainTextEdit *m_logPlainTextEdit;
...@@ -79,7 +79,6 @@ private: ...@@ -79,7 +79,6 @@ private:
VcsCommand *m_command; VcsCommand *m_command;
QString m_startedStatus; QString m_startedStatus;
QString m_error;
bool m_overwriteOutput; bool m_overwriteOutput;
State m_state; State m_state;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment