Skip to content

Commit

Permalink
issue #2816: Trimming tool crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Jan 23, 2017
1 parent 417f074 commit 43e8c21
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Mod/Sketcher/App/PropertyConstraintList.h
Expand Up @@ -86,7 +86,11 @@ class SketcherExport PropertyConstraintList : public App::PropertyLists
*/
void setValues(const std::vector<Constraint*>&);

/// 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];
}
Expand All @@ -112,7 +116,6 @@ class SketcherExport PropertyConstraintList : public App::PropertyLists
void acceptGeometry(const std::vector<Part::Geometry *> &GeoList);
void checkGeometry(const std::vector<Part::Geometry *> &GeoList);
bool scanGeometry(const std::vector<Part::Geometry *> &GeoList) const;
bool isGeometryInvalid(){return invalidGeometry;}

/// Return status of geometry for better error reporting
bool hasInvalidGeometry() const { return invalidGeometry; }
Expand Down
6 changes: 6 additions & 0 deletions src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp
Expand Up @@ -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;
Expand Down

0 comments on commit 43e8c21

Please sign in to comment.