From 88e3397ff9e0421bcc927c80be6d9061a8956ea5 Mon Sep 17 00:00:00 2001 From: asv Date: Wed, 2 Aug 2006 08:34:55 +0000 Subject: [PATCH] Yet another modification (this one from JFA) to fix the same problem: GetCommonParameters() either modifies a Study or returns NULL AttributeParameters. Hopefully this modification finally fixes the bug. --- src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx | 33 +++++++++++-------------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx index d6d6fcd17..373212d85 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx @@ -1527,28 +1527,25 @@ void SALOMEDSImpl_Study::Modify() //============================================================================ Handle(SALOMEDSImpl_AttributeParameter) SALOMEDSImpl_Study::GetCommonParameters(const char* theID, int theSavePoint) { -if(theSavePoint < 0) return NULL; + if (theSavePoint < 0) return NULL; Handle(SALOMEDSImpl_StudyBuilder) builder = NewBuilder(); Handle(SALOMEDSImpl_SObject) so = FindComponent((char*)theID); - if(so.IsNull()) so = builder->NewComponent((char*)theID); + if (so.IsNull()) so = builder->NewComponent((char*)theID); Handle(SALOMEDSImpl_AttributeParameter) attParam; - if(theSavePoint == 0) { //Get an attribute that is placed on the component itself. - builder->FindAttribute(so, attParam, "AttributeParameter"); - if ( attParam.IsNull() ) { // first call of GetCommonParameters on "Interface Applicative" component - Handle(TDF_Attribute) att = builder->FindOrCreateAttribute(so, "AttributeParameter"); - attParam = Handle(SALOMEDSImpl_AttributeParameter)::DownCast( att ); - } - } - else { // Try to find SObject that contains attribute parameter ... + + if (theSavePoint > 0) { // 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 ); + if ( !savePointLabel.IsNull() ) + so = GetSObject( savePointLabel ); + else // ... if it does not exist - create a new one + so = builder->NewObjectToTag( so, theSavePoint ); + } + + if (!so.IsNull()) { + builder->FindAttribute(so, attParam, "AttributeParameter"); + if ( attParam.IsNull() ) { // first call of GetCommonParameters on "Interface Applicative" component + Handle(TDF_Attribute) att = builder->FindOrCreateAttribute(so, "AttributeParameter"); + attParam = Handle(SALOMEDSImpl_AttributeParameter)::DownCast( att ); } } return attParam; -- 2.39.2