[graphics/digikam] core/libs/widgets/mainview: Fix crash in ThemeManager when the theme menu does not exist yet

Andreas Winther <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 7b3cad40ed25c908327b405b0d68b4948657cdd3 by Andreas Winther.
Committed on 18/07/2026 at 20:11.
Pushed by cgilles into branch 'master'.

Fix crash in ThemeManager when the theme menu does not exist yet

ThemeManager::updateCurrentDesktopDefaultThemePreview() dereferences
d->themeMenuActionGroup without a null check, unlike its siblings
currentThemeName() and setCurrentTheme() which both guard against it.
The action group is only created by populateThemeMenu() after the main
window has registered the menu via setThemeMenuAction().

When SetupMisc::applySettings() applies a changed application style
(HAVE_APPSTYLE_SUPPORT) before the theme menu exists, it calls
updateThemeMenu(): populateThemeMenu() bails out early because
themeMenuAction is still null, then slotChangePalette() runs
unconditionally and updateCurrentDesktopDefaultThemePreview()
dereferences the null action group. Verified with lldb on macOS
(Qt 6, Debug build): calling updateThemeMenu() before
setThemeMenuAction() crashes with EXC_BAD_ACCESS in
QActionGroup::actions(); with this guard the same call returns
cleanly and the palette is applied from the default theme.

Guard the preview update the same way as its sibling accessors.

M  +5    -0    core/libs/widgets/mainview/thememanager.cpp

https://invent.kde.org/graphics/digikam/-/commit/7b3cad40ed25c908327b405b0d68b4948657cdd3

diff --git a/core/libs/widgets/mainview/thememanager.cpp b/core/libs/widgets/mainview/thememanager.cpp
index 55c907463f..2be1dda8eb 100644
--- a/core/libs/widgets/mainview/thememanager.cpp
+++ b/core/libs/widgets/mainview/thememanager.cpp
@@ -202,6 +202,11 @@ void ThemeManager::populateThemeMenu()
 
 void ThemeManager::updateCurrentDesktopDefaultThemePreview()
 {
+    if (!d->themeMenuActionGroup)
+    {
+        return;
+    }
+
     QList<QAction*> list = d->themeMenuActionGroup->actions();
 
     for (QAction* const action : std::as_const(list))
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.