From fca2e2671a850b23a7496a8372dfe9b3c68a88b3 Mon Sep 17 00:00:00 2001 From: Eivind Kvedalen Date: Sun, 20 Dec 2015 14:09:34 +0100 Subject: [PATCH] PropertyConstraintList: Use correct indices when checking the constraint type. --- src/Mod/Sketcher/App/PropertyConstraintList.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Mod/Sketcher/App/PropertyConstraintList.cpp b/src/Mod/Sketcher/App/PropertyConstraintList.cpp index d270add33..aa132121c 100644 --- a/src/Mod/Sketcher/App/PropertyConstraintList.cpp +++ b/src/Mod/Sketcher/App/PropertyConstraintList.cpp @@ -422,9 +422,11 @@ void PropertyConstraintList::setPathValue(const ObjectIdentifier &path, const bo throw std::bad_cast(); if (c0.isArray() && path.numSubComponents() == 1) { + int index = c0.getIndex(); + if (c0.getIndex() >= _lValueList.size()) throw Base::Exception("Array out of bounds"); - switch (_lValueList[c0.getIndex()]->Type) { + switch (_lValueList[index]->Type) { case Angle: dvalue = Base::toRadians(dvalue); break; @@ -432,7 +434,7 @@ void PropertyConstraintList::setPathValue(const ObjectIdentifier &path, const bo break; } aboutToSetValue(); - _lValueList[c0.getIndex()]->setValue(dvalue); + _lValueList[index]->setValue(dvalue); hasSetValue(); return; } @@ -440,8 +442,10 @@ void PropertyConstraintList::setPathValue(const ObjectIdentifier &path, const bo ObjectIdentifier::Component c1 = path.getPropertyComponent(1); for (std::vector::const_iterator it = _lValueList.begin(); it != _lValueList.end(); ++it) { + int index = it - _lValueList.begin(); + if ((*it)->Name == c1.getName()) { - switch (_lValueList[c0.getIndex()]->Type) { + switch (_lValueList[index]->Type) { case Angle: dvalue = Base::toRadians(dvalue); break; @@ -449,7 +453,7 @@ void PropertyConstraintList::setPathValue(const ObjectIdentifier &path, const bo break; } aboutToSetValue(); - _lValueList[it - _lValueList.begin()]->setValue(dvalue); + _lValueList[index]->setValue(dvalue); hasSetValue(); return; }