From: nds Date: Mon, 19 Jan 2015 09:56:51 +0000 (+0300) Subject: Issue #355 Delete: elements of sketch and constraints X-Git-Tag: V_1.0.0~6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1b1e71dfeebba86d28729f7d6beb9fe2c48f4bf4;p=modules%2Fshaper.git Issue #355 Delete: elements of sketch and constraints Remove the first empty feature if the removed feature is not found in the list of sketch sub-elements. --- diff --git a/src/SketchPlugin/SketchPlugin_Sketch.cpp b/src/SketchPlugin/SketchPlugin_Sketch.cpp index a3cbc24b5..bda3bd879 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.cpp +++ b/src/SketchPlugin/SketchPlugin_Sketch.cpp @@ -138,16 +138,19 @@ void SketchPlugin_Sketch::removeFeature(ModelAPI_Feature* theFeature) list aSubs = data()->reflist(SketchPlugin_Sketch::FEATURES_ID())->list(); list::iterator aSubIt = aSubs.begin(), aLastIt = aSubs.end(); bool isRemoved = false; + bool aHasEmtpyFeature = false; for(; aSubIt != aLastIt && !isRemoved; aSubIt++) { std::shared_ptr aFeature = std::dynamic_pointer_cast(*aSubIt); - if (aFeature.get() != NULL || aFeature.get() == theFeature) { + if (aFeature.get() != NULL && aFeature.get() == theFeature) { data()->reflist(SketchPlugin_Sketch::FEATURES_ID())->remove(aFeature); isRemoved = true; } + else if (aFeature.get() == NULL) + aHasEmtpyFeature = true; } // if the object is not found in the sketch sub-elements, that means that the object is removed already. // Find the first empty element and remove it - if (!isRemoved) + if (!isRemoved && aHasEmtpyFeature) data()->reflist(SketchPlugin_Sketch::FEATURES_ID())->remove(NULL); }