From 0e111b6164825c70f0b491d558e79d36295da4cb Mon Sep 17 00:00:00 2001 From: Fedja Beader Date: Sun, 29 Jun 2025 16:14:41 +0200 Subject: Fix crash when deleting last mail and then pressing delete again .. wonder if this should be handled at ListBox level, instead. i.e. calling setModel again, but that might resize the listbox? Plus, would still want to select last mail, instead of invalidating index. --- src/gui/windows/mailwindow.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/gui/windows/mailwindow.cpp') diff --git a/src/gui/windows/mailwindow.cpp b/src/gui/windows/mailwindow.cpp index 4f5f9cac5..64dbb53e4 100644 --- a/src/gui/windows/mailwindow.cpp +++ b/src/gui/windows/mailwindow.cpp @@ -255,6 +255,12 @@ void MailWindow::removeMail(const int64_t id) if (message != nullptr) mMailModel->add(getMailHeader(message)); } + + const auto lastIndex = mMailModel->getNumberOfElements() - 1; + if (mListBox->getSelected() > lastIndex) + { + mListBox->setSelected(lastIndex); + } } void MailWindow::showMessage(MailMessage *const mail, -- cgit v1.2.3-70-g09d2