From: mpv Date: Tue, 11 Nov 2014 13:39:31 +0000 (+0300) Subject: To avoid possible crash on close X-Git-Tag: V_0.5^0 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=59d66ad7376d3ca30f210c20a0826c786e6a9570;p=modules%2Fshaper.git To avoid possible crash on close --- diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 06ec246f3..1c9028567 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -522,18 +522,20 @@ void Model_Document::removeFeature(FeaturePtr theFeature, const bool theCheck) } boost::shared_ptr aData = boost::static_pointer_cast(theFeature->data()); - TDF_Label aFeatureLabel = aData->label().Father(); - if (myObjs.IsBound(aFeatureLabel)) - myObjs.UnBind(aFeatureLabel); - else - return; // not found feature => do not remove - // erase fields - theFeature->erase(); - // erase all attributes under the label of feature - aFeatureLabel.ForgetAllAttributes(); - // remove it from the references array - if (theFeature->isInHistory()) { - RemoveFromRefArray(featuresLabel(), aFeatureLabel); + if (aData) { + TDF_Label aFeatureLabel = aData->label().Father(); + if (myObjs.IsBound(aFeatureLabel)) + myObjs.UnBind(aFeatureLabel); + else + return; // not found feature => do not remove + // erase fields + theFeature->erase(); + // erase all attributes under the label of feature + aFeatureLabel.ForgetAllAttributes(); + // remove it from the references array + if (theFeature->isInHistory()) { + RemoveFromRefArray(featuresLabel(), aFeatureLabel); + } } // event: feature is deleted ModelAPI_EventCreator::get()->sendDeleted(theFeature->document(), ModelAPI_Feature::group());