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:
Jonathan White 2019-10-22 22:47:45 -04:00
parent b8830dfd32
commit af263fd80d
3 changed files with 24 additions and 4 deletions

View file

@ -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;
}