diff options
author | Fedja Beader <fedja@protonmail.ch> | 2025-06-29 16:14:41 +0200 |
---|---|---|
committer | Fedja Beader <fedja@protonmail.ch> | 2025-06-29 16:16:32 +0200 |
commit | 0e111b6164825c70f0b491d558e79d36295da4cb (patch) | |
tree | ac8b355859e1e9d0ff2b099f24d0fca919252145 /src/gui/windows/mailwindow.cpp | |
parent | 427c4ba42ff64cdf4f9c370cfd9c29785a85d27c (diff) | |
download | manaplus-mail_delete_crash.tar.gz manaplus-mail_delete_crash.tar.bz2 manaplus-mail_delete_crash.tar.xz manaplus-mail_delete_crash.zip |
Fix crash when deleting last mail and then pressing delete againmail_delete_crash
.. 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.
Diffstat (limited to 'src/gui/windows/mailwindow.cpp')
-rw-r--r-- | src/gui/windows/mailwindow.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
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, |