From 5df128b21f889da470795b10039dca89f9465336 Mon Sep 17 00:00:00 2001 From: logari81 Date: Tue, 11 Oct 2011 21:22:55 +0000 Subject: [PATCH] + fix crashes on deleting Sketcher geometries + whitespace improvements git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5006 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d --- src/Mod/Sketcher/App/SketchObject.cpp | 18 ++++++++++++------ src/Mod/Sketcher/Gui/ViewProviderSketch.cpp | 4 ++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index ba5719770..3941a9cd2 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -247,16 +247,22 @@ int SketchObject::delGeometry(int GeoNbr) for (std::vector::const_iterator it = constraints.begin(); it != constraints.end(); ++it) { if ((*it)->First != GeoNbr && (*it)->Second != GeoNbr) { - if ((*it)->First > GeoNbr) - (*it)->First -= 1; - if ((*it)->Second > GeoNbr) - (*it)->Second -= 1; - newConstraints.push_back(*it); + Constraint *copiedConstr = (*it)->clone(); + if (copiedConstr->First > GeoNbr) + copiedConstr->First -= 1; + if (copiedConstr->Second > GeoNbr) + copiedConstr->Second -= 1; + newConstraints.push_back(copiedConstr); } } - this->Constraints.setValues(newConstraints); + // temporarily empty constraints list in order to avoid invalid constraints + // during manipulation of the geometry list + std::vector< Constraint * > emptyConstraints(0); + this->Constraints.setValues(emptyConstraints); + this->Geometry.setValues(newVals); + this->Constraints.setValues(newConstraints); rebuildVertexIndex(); return 0; } diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp index 25c50e4e7..853dab5d3 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -1483,6 +1483,7 @@ float ViewProviderSketch::getScaleFactor() return 1.f; } } + void ViewProviderSketch::draw(bool temp) { assert(edit); @@ -1669,7 +1670,7 @@ Restart: // get the geometry const Part::Geometry *geo = (*geomlist)[Constr->First]; // Vertical can only be a GeomLineSegment - assert(geo->getTypeId()== Part::GeomLineSegment::getClassTypeId()); + assert(geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()); const Part::GeomLineSegment *lineSeg = dynamic_cast(geo); // calculate the half distance between the start and endpoint @@ -2938,7 +2939,6 @@ Sketcher::SketchObject *ViewProviderSketch::getSketchObject(void) const return dynamic_cast(pcObject); } - bool ViewProviderSketch::onDelete(const std::vector &subList) { //FIXME use the selection subelements instead of the Sel Sets...