]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #84 fix: process unknown objects correctly
authormpv <mikhail.ponikarov@opencascade.com>
Tue, 29 Jul 2014 11:04:27 +0000 (15:04 +0400)
committermpv <mikhail.ponikarov@opencascade.com>
Tue, 29 Jul 2014 11:04:27 +0000 (15:04 +0400)
src/Model/Model_Document.cpp
src/SketchPlugin/SketchPlugin_Sketch.cpp

index a4c9729ae4594613d8a745d1c6e0b14a42efc013..9d8cb9b8a6ff1f58c0c29a0afcbe47237f224944 100644 (file)
@@ -644,6 +644,11 @@ void Model_Document::synchronizeFeatures(const bool theMarkUpdated)
       FeaturePtr aNewObj = ModelAPI_PluginManager::get()->createFeature(
         TCollection_AsciiString(Handle(TDataStd_Comment)::DownCast(aLabIter.Value())->Get())
         .ToCString());
+      if (!aNewObj) { // somethig is wrong, most probably, the opened document has invalid structure
+        Events_Error::send("Invalid type of object in the document");
+        aLabIter.Value()->Label().ForgetAllAttributes();
+        continue;
+      }
       // this must be before "setData" to redo the sketch line correctly
       myObjs.Bind(aFeatureLabel, aNewObj);
       aNewFeatures.insert(aNewObj);
index 288e4e5297b308d8c5aab90a98be643ed3405bf9..144caa3369e54ea25e8f89a6c54052a4fcf229b6 100644 (file)
@@ -41,7 +41,8 @@ void SketchPlugin_Sketch::execute()
   if (!data()->isValid())
     return ;
   boost::shared_ptr<ModelAPI_AttributeRefList> aRefList =
-    boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(data()->attribute(SketchPlugin_Sketch::FEATURES_ID()));
+    boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
+    data()->attribute(SketchPlugin_Sketch::FEATURES_ID()));
 
   boost::shared_ptr<GeomDataAPI_Point> anOrigin = 
     boost::dynamic_pointer_cast<GeomDataAPI_Point>(data()->attribute(SketchPlugin_Sketch::ORIGIN_ID()));