Salome HOME
Fix to bug SWP12996: "Modified" flag was incorrectly set on Study object in 2 cases:
authorasv <asv@opencascade.com>
Wed, 26 Jul 2006 06:42:50 +0000 (06:42 +0000)
committerasv <asv@opencascade.com>
Wed, 26 Jul 2006 06:42:50 +0000 (06:42 +0000)
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.

src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx
src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx

index ed054fb2ecb984c83154d96070ea83f389044640..2165d3e5f6fbe46ce1dc0e853f6c9282f9a72cd0 100644 (file)
@@ -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;
 }
 
 //============================================================================
index d47beb3dd8cd2e645a37834860f7c476337aa4b6..5c14d9cfc80ee156a731bad3f2232ab67308c8f0 100644 (file)
@@ -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;