Salome HOME
Issue #367: Make moved point equal to selected
[modules/shaper.git] / src / Model / Model_AttributeReference.cpp
index b2f27073d3e3e8f3bf2ba87cfe19cf32bd3d8fe2..43bbabe658fff74259890026c982b1302d55670c 100644 (file)
@@ -32,8 +32,8 @@ void Model_AttributeReference::setValue(ObjectPtr theObject)
         std::dynamic_pointer_cast<Model_Document>(owner()->document());
       myRef->Set(anObjLab);  // references to the object label
        // remove external link attributes (if any)
-      anObjLab.ForgetAttribute(TDataStd_Comment::GetID());
-      anObjLab.ForgetAttribute(TDataStd_AsciiString::GetID());
+      myRef->Label().ForgetAttribute(TDataStd_Comment::GetID());
+      myRef->Label().ForgetAttribute(TDataStd_AsciiString::GetID());
     } else { // different document: store the document name (comment) and entry (string): external
       // if these attributes exist, the link is external: keep reference to access the label
       TDataStd_Comment::Set(myRef->Label(), theObject->document()->id().c_str());
@@ -69,7 +69,9 @@ ObjectPtr Model_AttributeReference::value()
           owner()->document());
       if (aDoc) {
         TDF_Label aRefLab = myRef->Get();
-        return aDoc->object(aRefLab);
+        if (!aRefLab.IsNull()) {  // it may happen with old document, issue #285
+          return aDoc->object(aRefLab);
+        }
       }
     }
   }