Prevent crash when all entries are deleted from a group

* Fix #4093 - The first entry in the list is selected after deleting an entry
* Prevents crashes due to dangling pointers held by the Entry Preview Widget when entries were deleted.
* Improve GUI tests to ensure this new behavior occurs.
This commit is contained in:
Jonathan White 2020-01-10 22:28:31 -05:00
parent 6cde2b83e8
commit 0d3eb047c7
4 changed files with 31 additions and 4 deletions

View file

@ -154,6 +154,7 @@ DatabaseWidget::DatabaseWidget(QSharedPointer<Database> db, QWidget* parent)
m_shareLabel->setVisible(false);
#endif
m_previewView->setObjectName("previewWidget");
m_previewView->hide();
m_previewSplitter->addWidget(m_entryView);
m_previewSplitter->addWidget(m_previewView);
@ -552,6 +553,14 @@ void DatabaseWidget::deleteEntries(QList<Entry*> selectedEntries)
}
refreshSearch();
m_entryView->setFirstEntryActive();
auto* currentEntry = currentSelectedEntry();
if (currentEntry) {
m_previewView->setEntry(currentEntry);
} else {
m_previewView->setGroup(groupView()->currentGroup());
}
}
bool DatabaseWidget::confirmDeleteEntries(QList<Entry*> entries, bool permanent)