[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.
This commit is contained in:
Ajinkya Dahale
2023-01-13 06:40:05 +05:30
committed by wwmayer
parent 8466b68400
commit e47147ea37

View File

@@ -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<ConstraintItem*>(item)->sketchView->getSketchObject()->getDocument()->getName();
std::string obj_name = static_cast<ConstraintItem*>(item)->sketchView->getSketchObject()->getNameInDocument();