From: mpv Date: Tue, 29 Jul 2014 11:04:27 +0000 (+0400) Subject: Issue #84 fix: process unknown objects correctly X-Git-Tag: V_0.4.4~135 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=67b92ad7f2e5de8c032f0bbea941dea3534696dc;p=modules%2Fshaper.git Issue #84 fix: process unknown objects correctly --- diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index a4c9729ae..9d8cb9b8a 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -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); diff --git a/src/SketchPlugin/SketchPlugin_Sketch.cpp b/src/SketchPlugin/SketchPlugin_Sketch.cpp index 288e4e529..144caa336 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.cpp +++ b/src/SketchPlugin/SketchPlugin_Sketch.cpp @@ -41,7 +41,8 @@ void SketchPlugin_Sketch::execute() if (!data()->isValid()) return ; boost::shared_ptr aRefList = - boost::dynamic_pointer_cast(data()->attribute(SketchPlugin_Sketch::FEATURES_ID())); + boost::dynamic_pointer_cast( + data()->attribute(SketchPlugin_Sketch::FEATURES_ID())); boost::shared_ptr anOrigin = boost::dynamic_pointer_cast(data()->attribute(SketchPlugin_Sketch::ORIGIN_ID()));