Commit a6d8bbbb authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh
Browse files

VCS: Discard commit if submit widget is disabled



Change-Id: I8f11f56565f46919e93a30f754465de3bc44437e
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent bbdd0655
......@@ -1077,16 +1077,12 @@ bool GitPlugin::submitEditorAboutToClose()
return true;
// Prompt user. Force a prompt unless submit was actually invoked (that
// is, the editor was closed or shutdown).
VcsBase::VcsBaseSubmitEditor::PromptSubmitResult answer;
if (editor->forceClose()) {
answer = VcsBase::VcsBaseSubmitEditor::SubmitDiscarded;
} else {
bool promptData = false;
answer = editor->promptSubmit(tr("Closing Git Editor"),
tr("Do you want to commit the change?"),
tr("Git will not accept this commit. Do you want to continue to edit it?"),
&promptData, !m_submitActionTriggered, false);
}
bool promptData = false;
const VcsBase::VcsBaseSubmitEditor::PromptSubmitResult answer
= editor->promptSubmit(tr("Closing Git Editor"),
tr("Do you want to commit the change?"),
tr("Git will not accept this commit. Do you want to continue to edit it?"),
&promptData, !m_submitActionTriggered, false);
m_submitActionTriggered = false;
switch (answer) {
case VcsBase::VcsBaseSubmitEditor::SubmitCanceled:
......
......@@ -90,7 +90,6 @@ GitSubmitEditor::GitSubmitEditor(const VcsBase::VcsBaseSubmitEditorParameters *p
m_model(0),
m_commitEncoding(0),
m_commitType(SimpleCommit),
m_forceClose(false),
m_firstUpdate(true)
{
connect(this, SIGNAL(diffSelectedFiles(QList<int>)), this, SLOT(slotDiffSelected(QList<int>)));
......@@ -186,14 +185,12 @@ void GitSubmitEditor::updateFileModel()
QString errorMessage, commitTemplate;
CommitData data(m_commitType);
if (client->getCommitData(m_workingDirectory, &commitTemplate, data, &errorMessage)) {
m_forceClose = false;
setCommitData(data);
submitEditorWidget()->refreshLog(m_workingDirectory);
widget()->setEnabled(true);
} else {
// Nothing to commit left!
VcsBase::VcsBaseOutputWindow::instance()->appendError(errorMessage);
m_forceClose = true;
m_model->clear();
widget()->setEnabled(false);
}
......
......@@ -53,7 +53,6 @@ public:
void setCommitData(const CommitData &);
GitSubmitEditorPanelData panelData() const;
bool forceClose() { updateFileModel(); return m_forceClose; }
CommitType commitType() const { return m_commitType; }
QString amendSHA1() const;
......@@ -78,7 +77,6 @@ private:
QTextCodec *m_commitEncoding;
CommitType m_commitType;
QString m_amendSHA1;
bool m_forceClose;
QString m_workingDirectory;
bool m_firstUpdate;
};
......
......@@ -547,6 +547,9 @@ VcsBaseSubmitEditor::PromptSubmitResult
Core::EditorManager::activateEditor(this, Core::EditorManager::IgnoreNavigationHistory);
if (!submitWidget->isEnabled())
return SubmitDiscarded;
QString errorMessage;
QMessageBox::StandardButton answer = QMessageBox::Yes;
......
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