X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_AttributeRefAttr.cpp;h=f399ba5be5405853d6c4ed7882c27d37ba30af77;hb=5ee0ac732ede71b1a7784be6870c5f21f6782565;hp=2d900eb142221d089617a372e714d182ebf54aa2;hpb=368eb86f8835d384a102ad84410a6c825c597a8c;p=modules%2Fshaper.git diff --git a/src/Model/Model_AttributeRefAttr.cpp b/src/Model/Model_AttributeRefAttr.cpp index 2d900eb14..f399ba5be 100644 --- a/src/Model/Model_AttributeRefAttr.cpp +++ b/src/Model/Model_AttributeRefAttr.cpp @@ -7,6 +7,7 @@ #include "Model_AttributeRefAttr.h" #include "Model_Application.h" #include "Model_Data.h" +#include "Model_Objects.h" #include using namespace std; @@ -23,8 +24,10 @@ void Model_AttributeRefAttr::setAttr(std::shared_ptr theAttr string anID = aData->id(theAttr); if (myIsInitialized && object() == theAttr->owner() && myID->Get().IsEqual(anID.c_str())) return; // nothing is changed + REMOVE_BACK_REF(theAttr->owner()); myRef->Set(aData->label().Father()); myID->Set(aData->id(theAttr).c_str()); + ADD_BACK_REF(theAttr->owner()); owner()->data()->sendAttributeUpdated(this); } @@ -43,16 +46,9 @@ void Model_AttributeRefAttr::setObject(ObjectPtr theObject) { // the back reference from the previous object to the attribute should be removed ObjectPtr anObject = object(); - if (anObject.get() && anObject != theObject) { - FeaturePtr anOwnerFeature = std::dynamic_pointer_cast(owner()); - if (anOwnerFeature.get()) { - std::shared_ptr aData = std::dynamic_pointer_cast( - anObject->data()); - aData->removeBackReference(anOwnerFeature, id()); - } - } - if (theObject && (!myIsInitialized || myID->Get().Length() != 0 || object() != theObject)) { + REMOVE_BACK_REF(anObject); + std::shared_ptr aData = std::dynamic_pointer_cast( theObject->data()); myRef->Set(aData->label().Father()); @@ -64,8 +60,10 @@ void Model_AttributeRefAttr::setObject(ObjectPtr theObject) if (anOwnerFeature.get()) { aData->addBackReference(anOwnerFeature, id(), false); } + ADD_BACK_REF(theObject); owner()->data()->sendAttributeUpdated(this); } else if (theObject.get() == NULL) { + REMOVE_BACK_REF(anObject); myRef->Set(myRef->Label()); // reference to itself means that object is null myID->Set(""); // feature is identified by the empty ID owner()->data()->sendAttributeUpdated(this); @@ -79,7 +77,7 @@ ObjectPtr Model_AttributeRefAttr::object() owner()->document()); if (aDoc) { TDF_Label aRefLab = myRef->Get(); - return aDoc->object(aRefLab); + return aDoc->objects()->object(aRefLab); } } // not initialized