From 2fa65a5539c42f95bd25b0288a59c8dc82fa1269 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 2 Mar 2025 13:32:42 +0100 Subject: [PATCH] Start: Fix possible crash when opening Start page Procedure to trigger the crash: * Create a document * Create a spreadsheet and open it * Close the 3D view * Open the Start page * It may or may not crash but the program is in an undefined state The reason of the crash is caused by an inappropriate use of static_cast. This bug is caused by PR 17152. To fix the crash use dynamic_cast instead. If the cast fails it returns a null pointer instead of a dangling pointer. --- src/Mod/Start/Gui/StartView.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Mod/Start/Gui/StartView.cpp b/src/Mod/Start/Gui/StartView.cpp index 63ce17f892..8ef9dd78f3 100644 --- a/src/Mod/Start/Gui/StartView.cpp +++ b/src/Mod/Start/Gui/StartView.cpp @@ -417,8 +417,7 @@ void StartView::changeEvent(QEvent* event) _openFirstStart->setEnabled(true); Gui::Document* doc = Gui::Application::Instance->activeDocument(); if (doc) { - Gui::View3DInventor* view = static_cast(doc->getActiveView()); - if (view) { + if (auto view = dynamic_cast(doc->getActiveView())) { Gui::View3DInventorViewer* viewer = view->getViewer(); if (viewer->isEditing()) { _openFirstStart->setEnabled(false);