Skip to content

Commit

Permalink
Fix behavior when saving after canceling entry edit
Browse files Browse the repository at this point in the history
* Fixes #3141
* Clearing the entry edit widget prior to emitting the editFinished signal caused the widget to be marked modified and prevent new entries from being created. Use an explicit boolean to notify commit success.
* Don't clear password generator on canceling a cancel
* Don't discard changes if saving from a cancel produces an error
  • Loading branch information
droidmonkey committed May 31, 2019
1 parent c645e2e commit b90e9ee
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/gui/entry/EditEntryWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -962,25 +962,25 @@ void EditEntryWidget::cancel()
m_entry->setIcon(Entry::DefaultIconNumber);
}

bool accepted = false;
if (isModified()) {
auto result = MessageBox::question(this,
QString(),
tr("Entry has unsaved changes"),
MessageBox::Cancel | MessageBox::Save | MessageBox::Discard,
MessageBox::Cancel);
if (result == MessageBox::Cancel) {
m_mainUi->passwordGenerator->reset();
return;
}
if (result == MessageBox::Save) {
commitEntry();
setModified(false);
} else if (result == MessageBox::Save) {
accepted = true;
if (!commitEntry()) {
return;
}
}
}

clear();

emit editFinished(!isModified());
emit editFinished(accepted);
}

void EditEntryWidget::clear()
Expand Down

0 comments on commit b90e9ee

Please sign in to comment.