From a855b7eb8b836bd1aadd0cd403a340c000dfbb8a Mon Sep 17 00:00:00 2001 From: SZY <> Date: Thu, 28 Apr 2011 15:40:24 +0000 Subject: [PATCH] OCC18056 Exception during copying Array attribute with array(0,0) --- src/TDataStd/TDataStd_ByteArray.cxx | 4 +-- src/TDataStd/TDataStd_ExtStringArray.cxx | 4 +-- src/TDataStd/TDataStd_IntegerArray.cxx | 5 +-- src/TDataStd/TDataStd_RealArray.cxx | 4 +-- src/TDataStd/TDataStd_ReferenceArray.cdl | 3 +- src/TDataStd/TDataStd_ReferenceArray.cxx | 41 ++++++++++++++++++++---- 6 files changed, 46 insertions(+), 15 deletions(-) diff --git a/src/TDataStd/TDataStd_ByteArray.cxx b/src/TDataStd/TDataStd_ByteArray.cxx index bae2af3f59..017c6c8fe4 100755 --- a/src/TDataStd/TDataStd_ByteArray.cxx +++ b/src/TDataStd/TDataStd_ByteArray.cxx @@ -128,7 +128,7 @@ void TDataStd_ByteArray::ChangeArray (const Handle(TColStd_HArray1OfByte)& newAr Standard_Boolean aDimEqual = Standard_False; Standard_Integer i; - if ((Lower() || Upper()) && Lower() == aLower && Upper() == anUpper ) { + if ( Lower() == aLower && Upper() == anUpper ) { aDimEqual = Standard_True; if(isCheckItems) { Standard_Boolean isEqual = Standard_True; @@ -145,7 +145,7 @@ void TDataStd_ByteArray::ChangeArray (const Handle(TColStd_HArray1OfByte)& newAr Backup(); // Handles of myValue of current and backuped attributes will be different! - if(!aDimEqual) + if(myValue.IsNull() || !aDimEqual) myValue = new TColStd_HArray1OfByte(aLower, anUpper); for(i = aLower; i <= anUpper; i++) diff --git a/src/TDataStd/TDataStd_ExtStringArray.cxx b/src/TDataStd/TDataStd_ExtStringArray.cxx index 274c980c15..ea20e56069 100755 --- a/src/TDataStd/TDataStd_ExtStringArray.cxx +++ b/src/TDataStd/TDataStd_ExtStringArray.cxx @@ -145,7 +145,7 @@ void TDataStd_ExtStringArray::ChangeArray(const Handle(TColStd_HArray1OfExtended Standard_Boolean aDimEqual = Standard_False; Standard_Integer i; - if ((Lower() || Upper()) && Lower() == aLower && Upper() == anUpper ) { + if (Lower() == aLower && Upper() == anUpper ) { aDimEqual = Standard_True; Standard_Boolean isEqual = Standard_True; if(isCheckItems) { @@ -163,7 +163,7 @@ void TDataStd_ExtStringArray::ChangeArray(const Handle(TColStd_HArray1OfExtended Backup(); // Handles of myValue of current and backuped attributes will be different!!! - if(!aDimEqual) + if(myValue.IsNull() || !aDimEqual) myValue = new TColStd_HArray1OfExtendedString(aLower, anUpper); for(i = aLower; i <= anUpper; i++) diff --git a/src/TDataStd/TDataStd_IntegerArray.cxx b/src/TDataStd/TDataStd_IntegerArray.cxx index 2fe17b5d38..5aba81b563 100755 --- a/src/TDataStd/TDataStd_IntegerArray.cxx +++ b/src/TDataStd/TDataStd_IntegerArray.cxx @@ -145,7 +145,8 @@ void TDataStd_IntegerArray::ChangeArray(const Handle(TColStd_HArray1OfInteger)& Standard_Boolean aDimEqual = Standard_False; Standard_Integer i; #ifdef OCC2932 - if ((Lower() || Upper()) && Lower() == aLower && Upper() == anUpper ) { + + if(Lower() == aLower && Upper() == anUpper ) { aDimEqual = Standard_True; if(isCheckItems) { Standard_Boolean isEqual = Standard_True; @@ -163,7 +164,7 @@ void TDataStd_IntegerArray::ChangeArray(const Handle(TColStd_HArray1OfInteger)& Backup(); // Handles of myValue of current and backuped attributes will be different! - if(!aDimEqual) + if(myValue.IsNull() || !aDimEqual) myValue = new TColStd_HArray1OfInteger(aLower, anUpper); for(i = aLower; i <= anUpper; i++) diff --git a/src/TDataStd/TDataStd_RealArray.cxx b/src/TDataStd/TDataStd_RealArray.cxx index 40f4806201..e07faa55f5 100755 --- a/src/TDataStd/TDataStd_RealArray.cxx +++ b/src/TDataStd/TDataStd_RealArray.cxx @@ -146,7 +146,7 @@ void TDataStd_RealArray::ChangeArray(const Handle(TColStd_HArray1OfReal)& newArr Standard_Integer i; #ifdef OCC2932 - if ((Lower() || Upper()) && Lower() == aLower && Upper() == anUpper ) { + if (Lower() == aLower && Upper() == anUpper ) { aDimEqual = Standard_True; Standard_Boolean isEqual = Standard_True; if(isCheckItems) { @@ -164,7 +164,7 @@ void TDataStd_RealArray::ChangeArray(const Handle(TColStd_HArray1OfReal)& newArr Backup(); - if(!aDimEqual) + if(myValue.IsNull() || !aDimEqual) myValue = new TColStd_HArray1OfReal(aLower, anUpper); for(i = aLower; i <= anUpper; i++) diff --git a/src/TDataStd/TDataStd_ReferenceArray.cdl b/src/TDataStd/TDataStd_ReferenceArray.cdl index 227bd4d672..c4d9e8b43c 100755 --- a/src/TDataStd/TDataStd_ReferenceArray.cdl +++ b/src/TDataStd/TDataStd_ReferenceArray.cdl @@ -73,7 +73,8 @@ is returns HLabelArray1 from TDataStd; SetInternalArray (me : mutable; - values : HLabelArray1 from TDataStd); + values : HLabelArray1 from TDataStd; + isCheckItems : Boolean = Standard_True); ---Category: Methodes of TDF_Attribute diff --git a/src/TDataStd/TDataStd_ReferenceArray.cxx b/src/TDataStd/TDataStd_ReferenceArray.cxx index f441b55c89..46430a9c95 100755 --- a/src/TDataStd/TDataStd_ReferenceArray.cxx +++ b/src/TDataStd/TDataStd_ReferenceArray.cxx @@ -32,10 +32,9 @@ TDataStd_ReferenceArray::TDataStd_ReferenceArray() void TDataStd_ReferenceArray::Init(const Standard_Integer lower, const Standard_Integer upper) { + Standard_RangeError_Raise_if(upper < lower,"TDataStd_ReferenceArray::Init"); Backup(); - - if (upper >= lower) - myArray = new TDataStd_HLabelArray1(lower, upper); + myArray = new TDataStd_HLabelArray1(lower, upper); } //======================================================================= @@ -130,9 +129,39 @@ const Handle(TDataStd_HLabelArray1)& TDataStd_ReferenceArray::InternalArray () c //function : SetInternalArray //purpose : //======================================================================= -void TDataStd_ReferenceArray::SetInternalArray (const Handle(TDataStd_HLabelArray1)& values) +void TDataStd_ReferenceArray::SetInternalArray (const Handle(TDataStd_HLabelArray1)& values, + const Standard_Boolean isCheckItem) { - myArray = values; +// myArray = values; + Standard_Integer aLower = values->Lower(); + Standard_Integer anUpper = values->Upper(); + Standard_Boolean aDimEqual = Standard_False; + Standard_Integer i; + +#ifdef OCC2932 + if (Lower() == aLower && Upper() == anUpper ) { + aDimEqual = Standard_True; + Standard_Boolean isEqual = Standard_True; + if(isCheckItems) { + for(i = aLower; i <= anUpper; i++) { + if(myArray->Value(i) != values->Value(i)) { + isEqual = Standard_False; + break; + } + } + if(isEqual) + return; + } + } +#endif + + Backup(); + + if(myArray.IsNull() || !aDimEqual) + myArray = new TDataStd_HLabelArray1(aLower, anUpper); + + for(i = aLower; i <= anUpper; i++) + myArray->SetValue(i, values->Value(i)); } //======================================================================= @@ -141,7 +170,7 @@ void TDataStd_ReferenceArray::SetInternalArray (const Handle(TDataStd_HLabelArra //======================================================================= const Standard_GUID& TDataStd_ReferenceArray::ID () const { - return GetID(); + return GetID(); } //=======================================================================