From 661b5f976131f85b65dab139ac0422b048d9f40d Mon Sep 17 00:00:00 2001 From: asv Date: Tue, 1 Aug 2006 14:00:57 +0000 Subject: [PATCH] An error fixed: if GetCommonParameters() is called for the first time on "Interface Applicative" component, then it returns null attribute. It caused crashed when DumpStudy() is called. --- src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx | 45 ++++++++++++++----------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx index 2165d3e5f..d6d6fcd17 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx @@ -1527,26 +1527,31 @@ void SALOMEDSImpl_Study::Modify() //============================================================================ Handle(SALOMEDSImpl_AttributeParameter) SALOMEDSImpl_Study::GetCommonParameters(const char* theID, int theSavePoint) { - 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); - Handle(SALOMEDSImpl_AttributeParameter) attParam; - if(theSavePoint == 0) //Get an attribute that is placed on the component itself. - 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; +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); + 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 ... + 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; } //============================================================================ -- 2.39.2