From 43e8c2174350808b44656618ff8cb0c6f3e49b05 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 23 Jan 2017 19:06:48 +0100 Subject: [PATCH] issue #0002816: Trimming tool crashes --- src/Mod/Sketcher/App/PropertyConstraintList.h | 7 +++++-- src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp | 6 ++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Mod/Sketcher/App/PropertyConstraintList.h b/src/Mod/Sketcher/App/PropertyConstraintList.h index 17b67ec26182..e8f580208907 100644 --- a/src/Mod/Sketcher/App/PropertyConstraintList.h +++ b/src/Mod/Sketcher/App/PropertyConstraintList.h @@ -86,7 +86,11 @@ class SketcherExport PropertyConstraintList : public App::PropertyLists */ void setValues(const std::vector&); - /// index operator + /*! + Index operator + \note If the geometry is invalid then the index operator + returns null. This must be checked by the caller. + */ const Constraint *operator[] (const int idx) const { return invalidGeometry ? 0 : _lValueList[idx]; } @@ -112,7 +116,6 @@ class SketcherExport PropertyConstraintList : public App::PropertyLists void acceptGeometry(const std::vector &GeoList); void checkGeometry(const std::vector &GeoList); bool scanGeometry(const std::vector &GeoList) const; - bool isGeometryInvalid(){return invalidGeometry;} /// Return status of geometry for better error reporting bool hasInvalidGeometry() const { return invalidGeometry; } diff --git a/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp b/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp index e8934d1f338d..51549970bb0c 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp +++ b/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp @@ -102,6 +102,12 @@ class ConstraintItem : public QListWidgetItem const Sketcher::Constraint * constraint = sketch->Constraints[ConstraintNbr]; + // it can happen that the geometry of the sketch is tmp. invalid and thus + // the index operator returns null. + if (!constraint) { + return QVariant(); + } + if (role == Qt::EditRole) { if (value.isValid()) return value;