Fix behavior when saving after canceling entry edit

* 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
This commit is contained in:
Jonathan White 2019-05-30 23:23:04 -04:00
parent c645e2e303
commit b90e9ee428

View File

@ -962,6 +962,7 @@ void EditEntryWidget::cancel()
m_entry->setIcon(Entry::DefaultIconNumber);
}
bool accepted = false;
if (isModified()) {
auto result = MessageBox::question(this,
QString(),
@ -969,18 +970,17 @@ void EditEntryWidget::cancel()
MessageBox::Cancel | MessageBox::Save | MessageBox::Discard,
MessageBox::Cancel);
if (result == MessageBox::Cancel) {
m_mainUi->passwordGenerator->reset();
return;
} else if (result == MessageBox::Save) {
accepted = true;
if (!commitEntry()) {
return;
}
if (result == MessageBox::Save) {
commitEntry();
setModified(false);
}
}
clear();
emit editFinished(!isModified());
emit editFinished(accepted);
}
void EditEntryWidget::clear()