forked from qt-creator/qt-creator
Vcs: Report stderr messages in checkout wizard
Do not delay them till after the command has finished. Change-Id: I52984e1deeaeb33e3feba0a5b6b982059870f4b8 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -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)
|
|||||||
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)
|
|||||||
|
|
||||||
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) {
|
|
||||||
|
const bool success = (ok && exitCode == 0);
|
||||||
|
QString message;
|
||||||
|
QPalette palette;
|
||||||
|
|
||||||
|
if (success) {
|
||||||
m_state = Succeeded;
|
m_state = Succeeded;
|
||||||
QApplication::restoreOverrideCursor();
|
message = tr("Succeeded.");
|
||||||
m_statusLabel->setText(tr("Succeeded."));
|
|
||||||
QPalette palette;
|
|
||||||
palette.setColor(QPalette::Active, QPalette::Text, Qt::green);
|
palette.setColor(QPalette::Active, QPalette::Text, Qt::green);
|
||||||
m_statusLabel->setPalette(palette);
|
|
||||||
emit completeChanged();
|
|
||||||
emit terminated(true);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
m_logPlainTextEdit->appendPlainText(m_error);
|
|
||||||
if (m_state == Running) {
|
|
||||||
m_state = Failed;
|
m_state = Failed;
|
||||||
QApplication::restoreOverrideCursor();
|
message = tr("Failed.");
|
||||||
m_statusLabel->setText(tr("Failed."));
|
|
||||||
QPalette palette;
|
|
||||||
palette.setColor(QPalette::Active, QPalette::Text, Qt::red);
|
palette.setColor(QPalette::Active, QPalette::Text, Qt::red);
|
||||||
m_statusLabel->setPalette(palette);
|
|
||||||
emit terminated(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckoutProgressWizardPage::slotOutput(const QString &text)
|
m_statusLabel->setText(message);
|
||||||
|
m_statusLabel->setPalette(palette);
|
||||||
|
|
||||||
|
QApplication::restoreOverrideCursor();
|
||||||
|
|
||||||
|
if (success)
|
||||||
|
emit completeChanged();
|
||||||
|
emit terminated(success);
|
||||||
|
}
|
||||||
|
|
||||||
|
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:
|
|||||||
|
|
||||||
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:
|
|||||||
|
|
||||||
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;
|
||||||
|
|||||||
Reference in New Issue
Block a user