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.
This commit is contained in:
@@ -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<Gui::View3DInventor*>(doc->getActiveView());
|
||||
if (view) {
|
||||
if (auto view = dynamic_cast<Gui::View3DInventor*>(doc->getActiveView())) {
|
||||
Gui::View3DInventorViewer* viewer = view->getViewer();
|
||||
if (viewer->isEditing()) {
|
||||
_openFirstStart->setEnabled(false);
|
||||
|
||||
Reference in New Issue
Block a user