Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan White <support@dmapps.us>2019-10-23 05:47:45 +0300
committerJonathan White <support@dmapps.us>2019-10-24 05:47:59 +0300
commitaf263fd80df2f5434b691b19f5a180435a9f20b6 (patch)
tree8b6153302941cb10220fa80c9c65e7e21ee442dd /src/gui/DatabaseWidget.cpp
parentb8830dfd327cd07eeead394ef33a2b57487c0516 (diff)
Prevent new entry loss on database file reload
* Fix #3651 * Correct data loss when the database reloads due to a file change while creating a new entry. The issue occurred due to the "new parent group" pointer being invalid after the database is reloaded following merge. * Also fix re-selecting entries following database file reload. If the entry was moved out of the current group it would result in an assert hit. This fix prevents recursively looking for the entry.
Diffstat (limited to 'src/gui/DatabaseWidget.cpp')
-rw-r--r--src/gui/DatabaseWidget.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp
index 5e3c101c1..45645fa55 100644
--- a/src/gui/DatabaseWidget.cpp
+++ b/src/gui/DatabaseWidget.cpp
@@ -381,6 +381,12 @@ void DatabaseWidget::createEntry()
void DatabaseWidget::replaceDatabase(QSharedPointer<Database> db)
{
+ // Save off new parent UUID which will be valid when creating a new entry
+ QUuid newParentUuid;
+ if (m_newParent) {
+ newParentUuid = m_newParent->uuid();
+ }
+
// TODO: instead of increasing the ref count temporarily, there should be a clean
// break from the old database. Without this crashes occur due to the change
// signals triggering dangling pointers.
@@ -390,6 +396,15 @@ void DatabaseWidget::replaceDatabase(QSharedPointer<Database> db)
m_groupView->changeDatabase(m_db);
processAutoOpen();
+ // Restore the new parent group pointer, if not found default to the root group
+ // this prevents data loss when merging a database while creating a new entry
+ if (!newParentUuid.isNull()) {
+ m_newParent = m_db->rootGroup()->findGroupByUuid(newParentUuid);
+ if (!m_newParent) {
+ m_newParent = m_db->rootGroup();
+ }
+ }
+
emit databaseReplaced(oldDb, m_db);
#if defined(WITH_XC_KEESHARE)
@@ -1480,7 +1495,7 @@ void DatabaseWidget::restoreGroupEntryFocus(const QUuid& groupUuid, const QUuid&
auto group = m_db->rootGroup()->findGroupByUuid(groupUuid);
if (group) {
m_groupView->setCurrentGroup(group);
- auto entry = group->findEntryByUuid(entryUuid);
+ auto entry = group->findEntryByUuid(entryUuid, false);
if (entry) {
m_entryView->setCurrentEntry(entry);
}