From 4f0bb805d2c3dfdfc87c5000a6a3675da1d8b6c2 Mon Sep 17 00:00:00 2001 From: Akseli Lahtinen Date: Wed, 13 Nov 2024 11:41:45 +0200 Subject: [PATCH] generalviewsettingspage: Use qobject_cast instead of static_cast In generalViewSettingsPage, ActiveWindow is not necessarily a mainWindow, which can cause dolphin to crash. For example when user opens folder properties and then dolphin settings, this part thinks the folder settings is mainWindow. Instead of static_cast, use qobject_cast, since it will return nullptr if the DolphinMainWindow is not found. BUG:492741 --- src/settings/viewmodes/generalviewsettingspage.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/settings/viewmodes/generalviewsettingspage.cpp b/src/settings/viewmodes/generalviewsettingspage.cpp index c518147dd..00bbae296 100644 --- a/src/settings/viewmodes/generalviewsettingspage.cpp +++ b/src/settings/viewmodes/generalviewsettingspage.cpp @@ -126,7 +126,8 @@ GeneralViewSettingsPage::GeneralViewSettingsPage(const QUrl &url, QWidget *paren m_doubleClickViewComboBox->addItem(QIcon::fromTheme("list-add"), i18nc("@item:inlistbox", "Custom Command"), customCommand); m_doubleClickViewComboBox->insertSeparator(2); - DolphinMainWindow *mainWindow = static_cast(QApplication::activeWindow()); + DolphinMainWindow *mainWindow = qobject_cast(QApplication::activeWindow()); + if (mainWindow != nullptr) { KActionCollection *actions = mainWindow->actionCollection(); // get the allowed actions from actionCollection and add them to the combobox -- 2.47.3