From 604121610ff0c6c896667777968f45546f792b52 Mon Sep 17 00:00:00 2001 From: mpv Date: Fri, 11 Nov 2016 14:48:29 +0300 Subject: [PATCH] Fixed the crash on moving Group down and edit it in the issue #1862 --- src/ConstructionAPI/ConstructionAPI_Point.cpp | 1 - src/ExchangeAPI/ExchangeAPI_Export.cpp | 2 -- src/ExchangeAPI/ExchangeAPI_Import.cpp | 1 - src/Model/Model_SelectionNaming.cpp | 19 ++++++++++++------- src/ModelHighAPI/ModelHighAPI_Interface.cpp | 1 - src/ModelHighAPI/ModelHighAPI_Interface.h | 1 - src/ParametersAPI/ParametersAPI_Parameter.cpp | 1 - src/PartSetAPI/PartSetAPI_Part.cpp | 3 --- src/SketchAPI/SketchAPI_Sketch.cpp | 5 ----- 9 files changed, 12 insertions(+), 22 deletions(-) diff --git a/src/ConstructionAPI/ConstructionAPI_Point.cpp b/src/ConstructionAPI/ConstructionAPI_Point.cpp index 95e89ca4b..c5c722ef7 100644 --- a/src/ConstructionAPI/ConstructionAPI_Point.cpp +++ b/src/ConstructionAPI/ConstructionAPI_Point.cpp @@ -157,7 +157,6 @@ PointPtr addPoint(const std::shared_ptr& thePart, const ModelHighAPI_Double& theY, const ModelHighAPI_Double& theZ) { - // TODO(spo): check that thePart is not empty std::shared_ptr aFeature = thePart->addFeature(ConstructionAPI_Point::ID()); return PointPtr(new ConstructionAPI_Point(aFeature, theX, theY, theZ)); } diff --git a/src/ExchangeAPI/ExchangeAPI_Export.cpp b/src/ExchangeAPI/ExchangeAPI_Export.cpp index f0daad8f1..3f6b9fec6 100644 --- a/src/ExchangeAPI/ExchangeAPI_Export.cpp +++ b/src/ExchangeAPI/ExchangeAPI_Export.cpp @@ -16,7 +16,6 @@ void exportToFile(const std::shared_ptr & thePart, const std::list & theSelectionList, const std::string & theFileFormat) { - // TODO(spo): check that thePart is not empty std::shared_ptr aFeature = thePart->addFeature(ExchangePlugin_ExportFeature::ID()); fillAttribute("Regular", aFeature->string(ExchangePlugin_ExportFeature::EXPORT_TYPE_ID())); @@ -32,7 +31,6 @@ void exportToXAO(const std::shared_ptr & thePart, const std::string & theAuthor, const std::string & theGeometryName) { - // TODO(spo): check that thePart is not empty std::shared_ptr aFeature = thePart->addFeature(ExchangePlugin_ExportFeature::ID()); fillAttribute("XAO", aFeature->string(ExchangePlugin_ExportFeature::EXPORT_TYPE_ID())); diff --git a/src/ExchangeAPI/ExchangeAPI_Import.cpp b/src/ExchangeAPI/ExchangeAPI_Import.cpp index ff64ff5d9..dfa58a2d5 100644 --- a/src/ExchangeAPI/ExchangeAPI_Import.cpp +++ b/src/ExchangeAPI/ExchangeAPI_Import.cpp @@ -81,7 +81,6 @@ ImportPtr addImport( const std::shared_ptr & thePart, const std::string & theFilePath) { - // TODO(spo): check that thePart is not empty std::shared_ptr aFeature = thePart->addFeature(ExchangeAPI_Import::ID()); return ImportPtr(new ExchangeAPI_Import(aFeature, theFilePath)); } diff --git a/src/Model/Model_SelectionNaming.cpp b/src/Model/Model_SelectionNaming.cpp index 39b32c5e4..bc88078c6 100644 --- a/src/Model/Model_SelectionNaming.cpp +++ b/src/Model/Model_SelectionNaming.cpp @@ -252,15 +252,20 @@ std::string Model_SelectionNaming::namingName(ResultPtr& theContext, { TopTools_IndexedDataMapOfShapeListOfShape aMap; TopExp::MapShapesAndAncestors(aContext, TopAbs_VERTEX, TopAbs_FACE, aMap); - const TopTools_ListOfShape& aList2 = aMap.FindFromKey(aSubShape); TopTools_ListOfShape aList; TopTools_MapOfShape aFMap; - // fix is below - TopTools_ListIteratorOfListOfShape itl2(aList2); - for (int i = 1;itl2.More();itl2.Next(),i++) { - if(aFMap.Add(itl2.Value())) - aList.Append(itl2.Value()); - } + // simetimes when group is moved in history, naming may be badly updated, so + // avoid crash in FindFromKey (issue 1842) + if (aMap.Contains(aSubShape)) { + const TopTools_ListOfShape& aList2 = aMap.FindFromKey(aSubShape); + // fix is below + TopTools_ListIteratorOfListOfShape itl2(aList2); + for (int i = 1;itl2.More();itl2.Next(),i++) { + if(aFMap.Add(itl2.Value())) + aList.Append(itl2.Value()); + } + } else + break; int n = aList.Extent(); bool isByFaces = n >= 3; if(!isByFaces) { // open topology case or Compound case => via edges diff --git a/src/ModelHighAPI/ModelHighAPI_Interface.cpp b/src/ModelHighAPI/ModelHighAPI_Interface.cpp index 07fd0249a..51d6f036a 100644 --- a/src/ModelHighAPI/ModelHighAPI_Interface.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Interface.cpp @@ -81,7 +81,6 @@ void ModelHighAPI_Interface::setName(const std::string& theName) std::list ModelHighAPI_Interface::result() const { - // TODO(spo): should I use more common function for the whole model to prepare results? const_cast(this)->execute(); std::list aSelectionList; diff --git a/src/ModelHighAPI/ModelHighAPI_Interface.h b/src/ModelHighAPI/ModelHighAPI_Interface.h index 3c95aa903..669559d9a 100644 --- a/src/ModelHighAPI/ModelHighAPI_Interface.h +++ b/src/ModelHighAPI/ModelHighAPI_Interface.h @@ -58,7 +58,6 @@ public: MODELHIGHAPI_EXPORT void setName(const std::string& theName); - // TODO(spo): rename to selectAll() /// Return all objects of the feature MODELHIGHAPI_EXPORT virtual std::list result() const; diff --git a/src/ParametersAPI/ParametersAPI_Parameter.cpp b/src/ParametersAPI/ParametersAPI_Parameter.cpp index d562cf325..b6b9374fe 100644 --- a/src/ParametersAPI/ParametersAPI_Parameter.cpp +++ b/src/ParametersAPI/ParametersAPI_Parameter.cpp @@ -60,7 +60,6 @@ ParameterPtr addParameter(const std::shared_ptr & thePart, const std::string & theExpression, const std::string & theComment) { - // TODO(spo): check that thePart is not empty std::shared_ptr aFeature = thePart->addFeature(ParametersAPI_Parameter::ID()); return ParameterPtr(new ParametersAPI_Parameter(aFeature, theName, theExpression, theComment)); } diff --git a/src/PartSetAPI/PartSetAPI_Part.cpp b/src/PartSetAPI/PartSetAPI_Part.cpp index 6adbac259..63b3def93 100644 --- a/src/PartSetAPI/PartSetAPI_Part.cpp +++ b/src/PartSetAPI/PartSetAPI_Part.cpp @@ -42,7 +42,6 @@ void PartSetAPI_Part::dump(ModelHighAPI_Dumper& theDumper) const //-------------------------------------------------------------------------------------- PartPtr addPart(const std::shared_ptr & thePart) { - // TODO(spo): check that thePart is not empty std::shared_ptr aFeature = thePart->addFeature(PartSetAPI_Part::ID()); aFeature->execute(); return PartPtr(new PartSetAPI_Part(aFeature)); @@ -50,7 +49,6 @@ PartPtr addPart(const std::shared_ptr & thePart) PartPtr duplicatePart(const std::shared_ptr & thePart) { - // TODO(spo): check that thePart is not empty std::shared_ptr aFeature = thePart->addFeature(PartSetPlugin_Duplicate::ID()); aFeature->execute(); return PartPtr(new PartSetAPI_Part(aFeature)); @@ -58,7 +56,6 @@ PartPtr duplicatePart(const std::shared_ptr & thePart) void removePart(const std::shared_ptr & thePart) { - // TODO(spo): check that thePart is not empty std::shared_ptr aFeature = thePart->addFeature(PartSetPlugin_Remove::ID()); aFeature->execute(); } diff --git a/src/SketchAPI/SketchAPI_Sketch.cpp b/src/SketchAPI/SketchAPI_Sketch.cpp index 60c8165ef..cd9f9875c 100644 --- a/src/SketchAPI/SketchAPI_Sketch.cpp +++ b/src/SketchAPI/SketchAPI_Sketch.cpp @@ -124,8 +124,6 @@ void SketchAPI_Sketch::setValue( const std::shared_ptr & theConstraint, const ModelHighAPI_Double & theValue) { - // TODO(spo): check somehow that the feature is a constraint or eliminate - // crash if the feature have no real attribute VALUE fillAttribute(theValue, theConstraint->feature()->real(SketchPlugin_Constraint::VALUE())); // theConstraint->execute(); @@ -156,7 +154,6 @@ std::list SketchAPI_Sketch::selectFace() const SketchPtr addSketch(const std::shared_ptr & thePart, const std::shared_ptr & thePlane) { - // TODO(spo): check that thePart is not empty std::shared_ptr aFeature = thePart->addFeature(SketchAPI_Sketch::ID()); return SketchPtr(new SketchAPI_Sketch(aFeature, thePlane)); } @@ -164,7 +161,6 @@ SketchPtr addSketch(const std::shared_ptr & thePart, SketchPtr addSketch(const std::shared_ptr & thePart, const ModelHighAPI_Selection & theExternal) { - // TODO(spo): check that thePart is not empty std::shared_ptr aFeature = thePart->addFeature(SketchAPI_Sketch::ID()); return SketchPtr(new SketchAPI_Sketch(aFeature, theExternal)); } @@ -172,7 +168,6 @@ SketchPtr addSketch(const std::shared_ptr & thePart, SketchPtr addSketch(const std::shared_ptr & thePart, const std::string & theExternalName) { - // TODO(spo): check that thePart is not empty std::shared_ptr aFeature = thePart->addFeature(SketchAPI_Sketch::ID()); return SketchPtr( new SketchAPI_Sketch(aFeature, ModelHighAPI_Selection("FACE", theExternalName))); -- 2.30.2