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);
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()));