forked from qt-creator/qt-creator
Gerrit: Force remote refreshing on 401 error
Can happen if the password was changed. Change-Id: If0f0fa047c376c193ceda50e5465d016e16b61a3 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
75273506c1
commit
11e8ce65db
@@ -124,6 +124,11 @@ GerritDialog::GerritDialog(const QSharedPointer<GerritParameters> &p,
|
|||||||
m_refreshButton, &QWidget::setDisabled);
|
m_refreshButton, &QWidget::setDisabled);
|
||||||
connect(m_model, &GerritModel::refreshStateChanged,
|
connect(m_model, &GerritModel::refreshStateChanged,
|
||||||
this, &GerritDialog::slotRefreshStateChanged);
|
this, &GerritDialog::slotRefreshStateChanged);
|
||||||
|
connect(m_model, &GerritModel::errorText,
|
||||||
|
this, [this](const QString &text) {
|
||||||
|
if (text.contains("returned error: 401"))
|
||||||
|
updateRemotes(true);
|
||||||
|
}, Qt::QueuedConnection);
|
||||||
|
|
||||||
setCurrentPath(repository);
|
setCurrentPath(repository);
|
||||||
slotCurrentChanged();
|
slotCurrentChanged();
|
||||||
|
|||||||
@@ -233,6 +233,7 @@ public:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void resultRetrieved(const QByteArray &);
|
void resultRetrieved(const QByteArray &);
|
||||||
|
void errorText(const QString &text);
|
||||||
void finished();
|
void finished();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -247,6 +248,7 @@ private:
|
|||||||
QTimer m_timer;
|
QTimer m_timer;
|
||||||
QString m_binary;
|
QString m_binary;
|
||||||
QByteArray m_output;
|
QByteArray m_output;
|
||||||
|
QString m_error;
|
||||||
QFutureInterface<void> m_progress;
|
QFutureInterface<void> m_progress;
|
||||||
QFutureWatcher<void> m_watcher;
|
QFutureWatcher<void> m_watcher;
|
||||||
QStringList m_arguments;
|
QStringList m_arguments;
|
||||||
@@ -276,7 +278,9 @@ QueryContext::QueryContext(const QString &query,
|
|||||||
m_arguments = GerritServer::curlArguments() << url;
|
m_arguments = GerritServer::curlArguments() << url;
|
||||||
}
|
}
|
||||||
connect(&m_process, &QProcess::readyReadStandardError, this, [this] {
|
connect(&m_process, &QProcess::readyReadStandardError, this, [this] {
|
||||||
VcsOutputWindow::appendError(QString::fromLocal8Bit(m_process.readAllStandardError()));
|
const QString text = QString::fromLocal8Bit(m_process.readAllStandardError());
|
||||||
|
VcsOutputWindow::appendError(text);
|
||||||
|
m_error.append(text);
|
||||||
});
|
});
|
||||||
connect(&m_process, &QProcess::readyReadStandardOutput, this, [this] {
|
connect(&m_process, &QProcess::readyReadStandardOutput, this, [this] {
|
||||||
m_output.append(m_process.readAllStandardOutput());
|
m_output.append(m_process.readAllStandardOutput());
|
||||||
@@ -345,6 +349,7 @@ void QueryContext::processFinished(int exitCode, QProcess::ExitStatus es)
|
|||||||
{
|
{
|
||||||
if (m_timer.isActive())
|
if (m_timer.isActive())
|
||||||
m_timer.stop();
|
m_timer.stop();
|
||||||
|
emit errorText(m_error);
|
||||||
if (es != QProcess::NormalExit) {
|
if (es != QProcess::NormalExit) {
|
||||||
errorTermination(tr("%1 crashed.").arg(m_binary));
|
errorTermination(tr("%1 crashed.").arg(m_binary));
|
||||||
return;
|
return;
|
||||||
@@ -510,6 +515,7 @@ void GerritModel::refresh(const QSharedPointer<GerritServer> &server, const QStr
|
|||||||
|
|
||||||
m_query = new QueryContext(realQuery, m_parameters, *m_server, this);
|
m_query = new QueryContext(realQuery, m_parameters, *m_server, this);
|
||||||
connect(m_query, &QueryContext::resultRetrieved, this, &GerritModel::resultRetrieved);
|
connect(m_query, &QueryContext::resultRetrieved, this, &GerritModel::resultRetrieved);
|
||||||
|
connect(m_query, &QueryContext::errorText, this, &GerritModel::errorText);
|
||||||
connect(m_query, &QueryContext::finished, this, &GerritModel::queryFinished);
|
connect(m_query, &QueryContext::finished, this, &GerritModel::queryFinished);
|
||||||
emit refreshStateChanged(true);
|
emit refreshStateChanged(true);
|
||||||
m_query->start();
|
m_query->start();
|
||||||
|
|||||||
@@ -127,6 +127,7 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void refreshStateChanged(bool isRefreshing); // For disabling the "Refresh" button.
|
void refreshStateChanged(bool isRefreshing); // For disabling the "Refresh" button.
|
||||||
void stateChanged();
|
void stateChanged();
|
||||||
|
void errorText(const QString &text);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void resultRetrieved(const QByteArray &);
|
void resultRetrieved(const QByteArray &);
|
||||||
|
|||||||
Reference in New Issue
Block a user