Fix entry edit issues

* Fix #4083 - move auto-type checks early in the commit process to prevent half-saving an entry if there is a bail-out.

* Fix #4182 - prevent setting modified by just viewing auto-type window associations
This commit is contained in:
Jonathan White 2020-10-12 23:12:44 -04:00
parent 39f1504ca2
commit 1ed5cc9898
No known key found for this signature in database
GPG Key ID: 440FC65F2E0C6E01

View File

@ -997,6 +997,11 @@ bool EditEntryWidget::commitEntry()
return true;
}
// Check Auto-Type validity early
if (!AutoType::verifyAutoTypeSyntax(m_autoTypeUi->sequenceEdit->text())) {
return false;
}
if (m_advancedUi->attributesView->currentIndex().isValid() && m_advancedUi->attributesEdit->isEnabled()) {
QString key = m_attributesModel->keyByIndex(m_advancedUi->attributesView->currentIndex());
m_entryAttributes->set(key, m_advancedUi->attributesEdit->toPlainText(), m_entryAttributes->isProtected(key));
@ -1095,7 +1100,7 @@ void EditEntryWidget::updateEntryData(Entry* entry) const
entry->setAutoTypeEnabled(m_autoTypeUi->enableButton->isChecked());
if (m_autoTypeUi->inheritSequenceButton->isChecked()) {
entry->setDefaultAutoTypeSequence(QString());
} else if (AutoType::verifyAutoTypeSyntax(m_autoTypeUi->sequenceEdit->text())) {
} else {
entry->setDefaultAutoTypeSequence(m_autoTypeUi->sequenceEdit->text());
}
@ -1364,6 +1369,7 @@ void EditEntryWidget::removeAutoTypeAssoc()
void EditEntryWidget::loadCurrentAssoc(const QModelIndex& current)
{
bool modified = isModified();
if (current.isValid() && current.row() < m_autoTypeAssoc->size()) {
AutoTypeAssociations::Association assoc = m_autoTypeAssoc->get(current.row());
m_autoTypeUi->windowTitleCombo->setEditText(assoc.window);
@ -1379,6 +1385,7 @@ void EditEntryWidget::loadCurrentAssoc(const QModelIndex& current)
} else {
clearCurrentAssoc();
}
setModified(modified);
}
void EditEntryWidget::clearCurrentAssoc()