From 78f07f873128e1c976a56a41b10cde7c2f7f9615 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 14 Dec 2014 00:06:08 +0100 Subject: [PATCH] + fixes #0001790: Crash on undo/redo with a selection --- src/Mod/Sketcher/Gui/ViewProviderSketch.cpp | 75 +++++++++++---------- 1 file changed, 41 insertions(+), 34 deletions(-) diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp index a7d0f71566d5..145aa11998b8 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -1957,22 +1957,29 @@ void ViewProviderSketch::updateColor(void) //int32_t *index = edit->CurveSet->numVertices.startEditing(); // colors of the point set - if (edit->FullyConstrained) + if (edit->FullyConstrained) { for (int i=0; i < PtNum; i++) pcolor[i] = FullyConstrainedColor; - else + } + else { for (int i=0; i < PtNum; i++) pcolor[i] = VertexColor; + } - if (edit->PreselectCross == 0) + if (edit->PreselectCross == 0) { pcolor[0] = PreselectColor; - else if (edit->PreselectPoint != -1) - pcolor[edit->PreselectPoint + 1] = PreselectColor; + } + else if (edit->PreselectPoint != -1) { + if (edit->PreselectPoint + 1 < PtNum) + pcolor[edit->PreselectPoint + 1] = PreselectColor; + } - for (std::set::iterator it=edit->SelPointSet.begin(); - it != edit->SelPointSet.end(); it++) - pcolor[*it] = (*it==(edit->PreselectPoint + 1) && (edit->PreselectPoint != -1))? - PreselectSelectedColor:SelectColor; + for (std::set::iterator it = edit->SelPointSet.begin(); it != edit->SelPointSet.end(); ++it) { + if (*it < PtNum) { + pcolor[*it] = (*it==(edit->PreselectPoint + 1) && (edit->PreselectPoint != -1)) + ? PreselectSelectedColor : SelectColor; + } + } // colors of the curves //int intGeoCount = getSketchObject()->getHighestCurveIndex() + 1; @@ -1986,58 +1993,58 @@ void ViewProviderSketch::updateColor(void) int GeoId = edit->CurvIdToGeoId[i]; // CurvId has several vertex a ssociated to 1 material //edit->CurveSet->numVertices => [i] indicates number of vertex for line i. - int indexes=(edit->CurveSet->numVertices[i]); + int indexes = (edit->CurveSet->numVertices[i]); - bool selected=(edit->SelCurvSet.find(GeoId) != edit->SelCurvSet.end()); - bool preselected=(edit->PreselectCurve == GeoId); + bool selected = (edit->SelCurvSet.find(GeoId) != edit->SelCurvSet.end()); + bool preselected = (edit->PreselectCurve == GeoId); - if (selected && preselected){ + if (selected && preselected) { color[i] = PreselectSelectedColor; - for(int k=j; jgetGeometry(GeoId)->Construction) { color[i] = CurveDraftColor; - for(int k=j; jFullyConstrained) { color[i] = FullyConstrainedColor; - for(int k=j; j