┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkseli Lahtinen <[email protected]>2024-11-13 11:41:45 +0200
committerAkseli Lahtinen <[email protected]>2024-11-13 09:42:25 +0000
commit4f0bb805d2c3dfdfc87c5000a6a3675da1d8b6c2 (patch)
tree5460e93852d8103982eb51f1de754627186165b5
parent11403da5b36b5b8314e69b86cc88bcf6d7733bba (diff)
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
-rw-r--r--src/settings/viewmodes/generalviewsettingspage.cpp3
1 files changed, 2 insertions, 1 deletions
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<DolphinMainWindow *>(QApplication::activeWindow());
+ DolphinMainWindow *mainWindow = qobject_cast<DolphinMainWindow *>(QApplication::activeWindow());
+
if (mainWindow != nullptr) {
KActionCollection *actions = mainWindow->actionCollection();
// get the allowed actions from actionCollection and add them to the combobox