From e47147ea37913b29a063f04cd105795c599bdc3c Mon Sep 17 00:00:00 2001 From: Ajinkya Dahale Date: Fri, 13 Jan 2023 06:40:05 +0530 Subject: [PATCH] [Sketcher] Prevent dereferencing `nullptr` in `ConstraintView` Fixes #8104. As described in that issue, a crash happens under the following conditions: 1. A `DrawSketchHandler` is active. 2. No constraint is selected. 3. Context menu on the `ConstraintView` is triggered. --- src/Mod/Sketcher/Gui/TaskSketcherConstraints.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Sketcher/Gui/TaskSketcherConstraints.cpp b/src/Mod/Sketcher/Gui/TaskSketcherConstraints.cpp index a6fecae2fb..72e995e808 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherConstraints.cpp +++ b/src/Mod/Sketcher/Gui/TaskSketcherConstraints.cpp @@ -450,7 +450,7 @@ void ConstraintView::contextMenuEvent (QContextMenuEvent* event) bool didRelease = SketcherGui::ReleaseHandler(doc); // Sync the FreeCAD selection with the selection in the ConstraintView widget - if (didRelease) { + if (didRelease && item) { Gui::Selection().clearSelection(); std::string doc_name = static_cast(item)->sketchView->getSketchObject()->getDocument()->getName(); std::string obj_name = static_cast(item)->sketchView->getSketchObject()->getNameInDocument();