From 1ed5cc9898252ebce7a01e69c6e7eea050afddfb Mon Sep 17 00:00:00 2001 From: Jonathan White Date: Mon, 12 Oct 2020 23:12:44 -0400 Subject: [PATCH] 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 --- src/gui/entry/EditEntryWidget.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gui/entry/EditEntryWidget.cpp b/src/gui/entry/EditEntryWidget.cpp index d7d8b7b32..22105c4d2 100644 --- a/src/gui/entry/EditEntryWidget.cpp +++ b/src/gui/entry/EditEntryWidget.cpp @@ -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()