diff --git a/src/plugins/git/gerrit/gerritplugin.cpp b/src/plugins/git/gerrit/gerritplugin.cpp index 249c1e39d60..80f5f56d141 100644 --- a/src/plugins/git/gerrit/gerritplugin.cpp +++ b/src/plugins/git/gerrit/gerritplugin.cpp @@ -366,11 +366,17 @@ void GerritPlugin::push() QPointer dialog = new GerritPushDialog(topLevel, Core::ICore::mainWindow()); if (!dialog->localChangesFound()) { - QMessageBox::critical(Core::ICore::mainWindow(), tr("No Local Changes"), + QMessageBox::warning(Core::ICore::mainWindow(), tr("No Local Changes"), tr("Change from HEAD appears to be in remote branch already. Aborting.")); return; } + if (!dialog->valid()) { + QMessageBox::warning(Core::ICore::mainWindow(), tr("Initialization Failed"), + tr("Failed to initialize dialog. Aborting.")); + return; + } + if (dialog->exec() == QDialog::Rejected) return; diff --git a/src/plugins/git/gerrit/gerritpushdialog.cpp b/src/plugins/git/gerrit/gerritpushdialog.cpp index 538b0cf37b5..b981f69b52f 100644 --- a/src/plugins/git/gerrit/gerritpushdialog.cpp +++ b/src/plugins/git/gerrit/gerritpushdialog.cpp @@ -43,7 +43,8 @@ GerritPushDialog::GerritPushDialog(const QString &workingDir, QWidget *parent) : m_workingDir(workingDir), m_ui(new Ui::GerritPushDialog), m_remoteBranches(new QMap()), - m_localChangesFound(true) + m_localChangesFound(false), + m_valid(false) { setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); m_ui->setupUi(this); @@ -59,21 +60,21 @@ GerritPushDialog::GerritPushDialog(const QString &workingDir, QWidget *parent) : << QLatin1String("HEAD") << QLatin1String("--not")<< QLatin1String("--remotes"); if (!gitClient->synchronousLog(m_workingDir, args, &output) || output.isEmpty()) - reject(); + return; output.chop(1); if (output.isEmpty()) { - output = QLatin1String("HEAD"); - m_localChangesFound = false; + return; } else { output = output.mid(output.lastIndexOf(QLatin1Char('\n')) + 1); + m_localChangesFound = true; } args.clear(); args << QLatin1String("--remotes") << QLatin1String("--contains") << output; if (!gitClient->synchronousBranchCmd(m_workingDir, args, &output, &error)) - reject(); + return; QString head = QLatin1String("/HEAD"); QStringList refs = output.split(QLatin1Char('\n')); @@ -93,7 +94,7 @@ GerritPushDialog::GerritPushDialog(const QString &workingDir, QWidget *parent) : args << QLatin1String("--remotes"); if (!gitClient->synchronousBranchCmd(m_workingDir, args, &output, &error)) - reject(); + return; refs.clear(); refs = output.split(QLatin1String("\n")); @@ -117,7 +118,6 @@ GerritPushDialog::GerritPushDialog(const QString &workingDir, QWidget *parent) : } const int remoteCount = m_ui->remoteComboBox->count(); if (remoteCount < 1) { - reject(); return; } else if (remoteCount == 1) { m_ui->remoteLabel->hide(); @@ -127,6 +127,7 @@ GerritPushDialog::GerritPushDialog(const QString &workingDir, QWidget *parent) : } connect(m_ui->branchComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setChangeRange())); setRemoteBranches(); + m_valid = true; } GerritPushDialog::~GerritPushDialog() @@ -169,6 +170,11 @@ bool GerritPushDialog::localChangesFound() const return m_localChangesFound; } +bool GerritPushDialog::valid() const +{ + return m_valid; +} + void GerritPushDialog::setRemoteBranches() { m_ui->branchComboBox->clear(); diff --git a/src/plugins/git/gerrit/gerritpushdialog.h b/src/plugins/git/gerrit/gerritpushdialog.h index c976dbb1eb2..8bbddcaaf1f 100644 --- a/src/plugins/git/gerrit/gerritpushdialog.h +++ b/src/plugins/git/gerrit/gerritpushdialog.h @@ -53,6 +53,7 @@ public: QString selectedTopic() const; QString reviewers() const; bool localChangesFound() const; + bool valid() const; private slots: void setChangeRange(); @@ -66,6 +67,7 @@ private: Ui::GerritPushDialog *m_ui; QMap *m_remoteBranches; bool m_localChangesFound; + bool m_valid; };