From: asv Date: Wed, 26 Jul 2006 06:42:50 +0000 (+0000) Subject: Fix to bug SWP12996: "Modified" flag was incorrectly set on Study object in 2 cases: X-Git-Tag: LAST_STABLE_VERSION_21_09_2006_ON_3_2_0~18 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=79e5116b1b5553eaf7e711ad28944a7f6ecfb573;p=modules%2Fkernel.git Fix to bug SWP12996: "Modified" flag was incorrectly set on Study object in 2 cases: 1) GetAttributeParameters() method always called FindOrCreateAttribute(), even when attribute was found and no creation was done. FindOrCreateAttribute always sets "Modified" flag on internal document. 2) Builder::FindAttribute() called _doc->Modify() which seems to be an error because no real modification to labels or attributes is done in this case. --- diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx index ed054fb2e..2165d3e5f 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx @@ -1531,12 +1531,22 @@ Handle(SALOMEDSImpl_AttributeParameter) SALOMEDSImpl_Study::GetCommonParameters( Handle(SALOMEDSImpl_StudyBuilder) builder = NewBuilder(); Handle(SALOMEDSImpl_SObject) so = FindComponent((char*)theID); if(so.IsNull()) so = builder->NewComponent((char*)theID); - Handle(SALOMEDSImpl_SObject) newSO; + Handle(SALOMEDSImpl_AttributeParameter) attParam; if(theSavePoint == 0) //Get an attribute that is placed on the component itself. - newSO = so; - else - newSO = builder->NewObjectToTag(so, theSavePoint); - return Handle(SALOMEDSImpl_AttributeParameter)::DownCast(builder->FindOrCreateAttribute(newSO, "AttributeParameter")); + builder->FindAttribute(so, attParam, "AttributeParameter"); + else { // Try to find SObject that contains attribute parameter ... + TDF_Label savePointLabel = so->GetLabel().FindChild( theSavePoint, /*create=*/0 ); + if ( !savePointLabel.IsNull() ) { + so = GetSObject( savePointLabel ); + builder->FindAttribute(so, attParam, "AttributeParameter"); + } // ... if it does not exist - create a new one + else { + so = builder->NewObjectToTag( so, theSavePoint ); + Handle(TDF_Attribute) att = builder->FindOrCreateAttribute(so, "AttributeParameter"); + attParam = Handle(SALOMEDSImpl_AttributeParameter)::DownCast( att ); + } + } + return attParam; } //============================================================================ diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx index d47beb3dd..5c14d9cfc 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx @@ -524,7 +524,8 @@ bool SALOMEDSImpl_StudyBuilder::FindAttribute(const Handle(SALOMEDSImpl_SObject) } TDF_Label Lab = anObject->GetLabel(); if (Lab.FindAttribute(SALOMEDSImpl_SObject::GetGUID(aTypeOfAttribute), anAttribute)) { - _doc->Modify(); + // _doc->Modify(); + // ASV: 26.07.06 : commented out because NO MODIFICATION is done to attributes when calling FindAttribute().. return Standard_True; } return Standard_False;