]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
To avoid possible crash on close V_0.5
authormpv <mikhail.ponikarov@opencascade.com>
Tue, 11 Nov 2014 13:39:31 +0000 (16:39 +0300)
committermpv <mikhail.ponikarov@opencascade.com>
Tue, 11 Nov 2014 13:39:31 +0000 (16:39 +0300)
src/Model/Model_Document.cpp

index 06ec246f36628794ecb0fccc6cf4b68aa5836418..1c902856732f4aa9100a62885cc807cb1870db9d 100644 (file)
@@ -522,18 +522,20 @@ void Model_Document::removeFeature(FeaturePtr theFeature, const bool theCheck)
   }
 
   boost::shared_ptr<Model_Data> aData = boost::static_pointer_cast<Model_Data>(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());