X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_AttributeReference.cpp;h=9c51e545b66ee0983cfcb17eb8747ce7dfe96654;hb=9b0703c45ab066f8421c72865b1b701f5c169860;hp=43bbabe658fff74259890026c982b1302d55670c;hpb=dc158ea248a9bbd70675887f494388c93e1b3b4d;p=modules%2Fshaper.git diff --git a/src/Model/Model_AttributeReference.cpp b/src/Model/Model_AttributeReference.cpp index 43bbabe65..9c51e545b 100644 --- a/src/Model/Model_AttributeReference.cpp +++ b/src/Model/Model_AttributeReference.cpp @@ -21,10 +21,13 @@ void Model_AttributeReference::setValue(ObjectPtr theObject) { if(!theObject) return; - if (!myIsInitialized || value() != theObject) { - std::shared_ptr aData = std::dynamic_pointer_cast( - theObject->data()); - TDF_Label anObjLab = aData->label().Father(); // object label + ObjectPtr aValue = value(); + if (!myIsInitialized || aValue != theObject) { + REMOVE_BACK_REF(aValue); + + std::shared_ptr aData = std::dynamic_pointer_cast( + theObject->data()); + TDF_Label anObjLab = aData->label().Father(); // object label if (owner()->document() == theObject->document()) { // same document, use reference attribute @@ -41,6 +44,9 @@ void Model_AttributeReference::setValue(ObjectPtr theObject) TDF_Tool::Entry(anObjLab, anEntry); TDataStd_AsciiString::Set(myRef->Label(), anEntry); } + // do it before the transaction finish to make just created/removed objects know dependencies + // and reference from composite feature is removed automatically + ADD_BACK_REF(theObject); owner()->data()->sendAttributeUpdated(this); }