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

@ -145,10 +145,12 @@ void EntryPreviewWidget::setDatabaseMode(DatabaseWidget::Mode mode)
}
if (mode == DatabaseWidget::Mode::ViewMode) {
if (m_ui->stackedWidget->currentWidget() == m_ui->pageGroup) {
if (m_currentGroup && m_ui->stackedWidget->currentWidget() == m_ui->pageGroup) {
setGroup(m_currentGroup);
} else {
} else if (m_currentEntry) {
setEntry(m_currentEntry);
} else {
hide();
}
}
}