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.
This commit is contained in:
@@ -585,13 +585,18 @@ QList<Entry*> Group::referencesRecursive(const Entry* entry) const
|
||||
[entry](const Entry* e) { return e->hasReferencesTo(entry->uuid()); });
|
||||
}
|
||||
|
||||
Entry* Group::findEntryByUuid(const QUuid& uuid) const
|
||||
Entry* Group::findEntryByUuid(const QUuid& uuid, bool recursive) const
|
||||
{
|
||||
if (uuid.isNull()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
for (Entry* entry : entriesRecursive(false)) {
|
||||
auto entries = m_entries;
|
||||
if (recursive) {
|
||||
entries = entriesRecursive(false);
|
||||
}
|
||||
|
||||
for (auto entry : entries) {
|
||||
if (entry->uuid() == uuid) {
|
||||
return entry;
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ public:
|
||||
static const QString RootAutoTypeSequence;
|
||||
|
||||
Group* findChildByName(const QString& name);
|
||||
Entry* findEntryByUuid(const QUuid& uuid) const;
|
||||
Entry* findEntryByUuid(const QUuid& uuid, bool recursive = true) const;
|
||||
Entry* findEntryByPath(const QString& entryPath);
|
||||
Entry* findEntryBySearchTerm(const QString& term, EntryReferenceType referenceType);
|
||||
Group* findGroupByUuid(const QUuid& uuid);
|
||||
|
||||
Reference in New Issue
Block a user