[pim/kmail/release/26.08] src: Fix bug 523845: KMail Segmentation fault

Laurent Montel <[email protected]> Tue, 4 Aug 2026 11:28:04 +0000 (UTC)
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 95d33923481639fd6794a9bf5a604052db8f34d5 by Laurent Montel.
Committed on 04/08/2026 at 11:28.
Pushed by mlaurent into branch 'release/26.08'.

Fix bug 523845: KMail Segmentation fault

Panel can be null
BUG: 523845

(cherry picked from commit 14fd09fe4f5fcb97d8b045a83d99df224f6956ad)

M  +5    -0    src/kmmainwidget.cpp

https://invent.kde.org/pim/kmail/-/commit/95d33923481639fd6794a9bf5a604052db8f34d5

diff --git a/src/kmmainwidget.cpp b/src/kmmainwidget.cpp
index f62acfe42..90e602296 100644
--- a/src/kmmainwidget.cpp
+++ b/src/kmmainwidget.cpp
@@ -540,6 +540,11 @@ void KMMainWidget::slotFolderChanged(const Akonadi::Collection &collection)
 
 void KMMainWidget::slotHistorySwitchFolder(const Akonadi::Collection &collection)
 {
+    // mMessagePane may be null if this slot fires during createWidgets() before
+    // the CollectionPane constructor has returned and assigned mMessagePane.
+    if (!mMessagePane) {
+        return;
+    }
     if (mCurrentCollection == collection) {
         return;
     }