From 9bc482067e6764364a246c1e78dd40c6218b0e3d Mon Sep 17 00:00:00 2001 From: srn Date: Wed, 4 Apr 2007 06:23:33 +0000 Subject: [PATCH] Increased a size of buffer to store the attribute ID and the read from file study. --- src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx | 8 +++++--- src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx | 8 ++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx index f963a80c4..bc23ce57b 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx @@ -476,14 +476,16 @@ Handle(TDF_Attribute) SALOMEDSImpl_StudyBuilder::FindOrCreateAttribute(const Han //The macro adds all necessary checks for standardly behaiving attributes __FindOrCreateAttributeForBuilder - + + //Add checks for TreeNode and UserID attributes if (strncmp(aTypeOfAttribute.ToCString(), "AttributeTreeNode",17) == 0 ) { + Standard_GUID aTreeNodeGUID; if (strcmp(aTypeOfAttribute.ToCString(), "AttributeTreeNode") == 0) { aTreeNodeGUID = SALOMEDSImpl_AttributeTreeNode::GetDefaultTreeID(); } else { - char* aGUIDString = new char[40]; + char* aGUIDString = new char[41]; char* aType = (char*)aTypeOfAttribute.ToCString(); sprintf(aGUIDString, &(aType[17])); if(!Standard_GUID::CheckGUIDFormat(aGUIDString)) { @@ -506,7 +508,7 @@ Handle(TDF_Attribute) SALOMEDSImpl_StudyBuilder::FindOrCreateAttribute(const Han if (strcmp(aTypeOfAttribute.ToCString(), "AttributeUserID") == 0) { aUserGUID = SALOMEDSImpl_AttributeUserID::DefaultID(); } else { - char* aGUIDString = new char[40]; + char* aGUIDString = new char[41]; char* aType = (char*)aTypeOfAttribute.ToCString(); sprintf(aGUIDString, &(aType[15])); if(!Standard_GUID::CheckGUIDFormat(aGUIDString)) { diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx index dd91556cd..17bad0e6a 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx @@ -1170,9 +1170,9 @@ static void ReadAttributes(const Handle(SALOMEDSImpl_Study)& theStudy, Handle(TDF_Attribute) anAttr; - char* current_string = new char[hdf_dataset->GetSize()]; + char* current_string = new char[hdf_dataset->GetSize()+1]; hdf_dataset->ReadFromDisk(current_string); - + if (!strcmp(hdf_dataset->GetName(),"COMPONENTDATATYPE")) { anAttr = theStudy->NewBuilder()->FindOrCreateAttribute(aSO, "AttributeComment"); } else if (!strcmp(hdf_dataset->GetName(),"AttributeReference") || @@ -1184,14 +1184,14 @@ static void ReadAttributes(const Handle(SALOMEDSImpl_Study)& theStudy, } else { anAttr = theStudy->NewBuilder()->FindOrCreateAttribute(aSO, hdf_dataset->GetName()); } - + if (!anAttr.IsNull()) { Handle(SALOMEDSImpl_GenericAttribute) ga = Handle(SALOMEDSImpl_GenericAttribute)::DownCast(anAttr); ga->Load(current_string); //cout << "Reading: " << aSO->GetID() << " "<< ga->Type() << " value: " << current_string << endl; } - + delete(current_string); hdf_dataset->CloseOnDisk(); } -- 2.39.2