1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-05 18:16:23 +03:00

OCC18056 Exception during copying Array attribute with array(0,0)

This commit is contained in:
SZY 2011-04-28 15:40:24 +00:00 committed by bugmaster
parent 762aacaed7
commit a855b7eb8b
6 changed files with 46 additions and 15 deletions

View File

@ -128,7 +128,7 @@ void TDataStd_ByteArray::ChangeArray (const Handle(TColStd_HArray1OfByte)& newAr
Standard_Boolean aDimEqual = Standard_False; Standard_Boolean aDimEqual = Standard_False;
Standard_Integer i; Standard_Integer i;
if ((Lower() || Upper()) && Lower() == aLower && Upper() == anUpper ) { if ( Lower() == aLower && Upper() == anUpper ) {
aDimEqual = Standard_True; aDimEqual = Standard_True;
if(isCheckItems) { if(isCheckItems) {
Standard_Boolean isEqual = Standard_True; Standard_Boolean isEqual = Standard_True;
@ -145,7 +145,7 @@ void TDataStd_ByteArray::ChangeArray (const Handle(TColStd_HArray1OfByte)& newAr
Backup(); Backup();
// Handles of myValue of current and backuped attributes will be different! // Handles of myValue of current and backuped attributes will be different!
if(!aDimEqual) if(myValue.IsNull() || !aDimEqual)
myValue = new TColStd_HArray1OfByte(aLower, anUpper); myValue = new TColStd_HArray1OfByte(aLower, anUpper);
for(i = aLower; i <= anUpper; i++) for(i = aLower; i <= anUpper; i++)

View File

@ -145,7 +145,7 @@ void TDataStd_ExtStringArray::ChangeArray(const Handle(TColStd_HArray1OfExtended
Standard_Boolean aDimEqual = Standard_False; Standard_Boolean aDimEqual = Standard_False;
Standard_Integer i; Standard_Integer i;
if ((Lower() || Upper()) && Lower() == aLower && Upper() == anUpper ) { if (Lower() == aLower && Upper() == anUpper ) {
aDimEqual = Standard_True; aDimEqual = Standard_True;
Standard_Boolean isEqual = Standard_True; Standard_Boolean isEqual = Standard_True;
if(isCheckItems) { if(isCheckItems) {
@ -163,7 +163,7 @@ void TDataStd_ExtStringArray::ChangeArray(const Handle(TColStd_HArray1OfExtended
Backup(); Backup();
// Handles of myValue of current and backuped attributes will be different!!! // Handles of myValue of current and backuped attributes will be different!!!
if(!aDimEqual) if(myValue.IsNull() || !aDimEqual)
myValue = new TColStd_HArray1OfExtendedString(aLower, anUpper); myValue = new TColStd_HArray1OfExtendedString(aLower, anUpper);
for(i = aLower; i <= anUpper; i++) for(i = aLower; i <= anUpper; i++)

View File

@ -145,7 +145,8 @@ void TDataStd_IntegerArray::ChangeArray(const Handle(TColStd_HArray1OfInteger)&
Standard_Boolean aDimEqual = Standard_False; Standard_Boolean aDimEqual = Standard_False;
Standard_Integer i; Standard_Integer i;
#ifdef OCC2932 #ifdef OCC2932
if ((Lower() || Upper()) && Lower() == aLower && Upper() == anUpper ) {
if(Lower() == aLower && Upper() == anUpper ) {
aDimEqual = Standard_True; aDimEqual = Standard_True;
if(isCheckItems) { if(isCheckItems) {
Standard_Boolean isEqual = Standard_True; Standard_Boolean isEqual = Standard_True;
@ -163,7 +164,7 @@ void TDataStd_IntegerArray::ChangeArray(const Handle(TColStd_HArray1OfInteger)&
Backup(); Backup();
// Handles of myValue of current and backuped attributes will be different! // Handles of myValue of current and backuped attributes will be different!
if(!aDimEqual) if(myValue.IsNull() || !aDimEqual)
myValue = new TColStd_HArray1OfInteger(aLower, anUpper); myValue = new TColStd_HArray1OfInteger(aLower, anUpper);
for(i = aLower; i <= anUpper; i++) for(i = aLower; i <= anUpper; i++)

View File

@ -146,7 +146,7 @@ void TDataStd_RealArray::ChangeArray(const Handle(TColStd_HArray1OfReal)& newArr
Standard_Integer i; Standard_Integer i;
#ifdef OCC2932 #ifdef OCC2932
if ((Lower() || Upper()) && Lower() == aLower && Upper() == anUpper ) { if (Lower() == aLower && Upper() == anUpper ) {
aDimEqual = Standard_True; aDimEqual = Standard_True;
Standard_Boolean isEqual = Standard_True; Standard_Boolean isEqual = Standard_True;
if(isCheckItems) { if(isCheckItems) {
@ -164,7 +164,7 @@ void TDataStd_RealArray::ChangeArray(const Handle(TColStd_HArray1OfReal)& newArr
Backup(); Backup();
if(!aDimEqual) if(myValue.IsNull() || !aDimEqual)
myValue = new TColStd_HArray1OfReal(aLower, anUpper); myValue = new TColStd_HArray1OfReal(aLower, anUpper);
for(i = aLower; i <= anUpper; i++) for(i = aLower; i <= anUpper; i++)

View File

@ -73,7 +73,8 @@ is
returns HLabelArray1 from TDataStd; returns HLabelArray1 from TDataStd;
SetInternalArray (me : mutable; SetInternalArray (me : mutable;
values : HLabelArray1 from TDataStd); values : HLabelArray1 from TDataStd;
isCheckItems : Boolean = Standard_True);
---Category: Methodes of TDF_Attribute ---Category: Methodes of TDF_Attribute

View File

@ -32,10 +32,9 @@ TDataStd_ReferenceArray::TDataStd_ReferenceArray()
void TDataStd_ReferenceArray::Init(const Standard_Integer lower, void TDataStd_ReferenceArray::Init(const Standard_Integer lower,
const Standard_Integer upper) const Standard_Integer upper)
{ {
Standard_RangeError_Raise_if(upper < lower,"TDataStd_ReferenceArray::Init");
Backup(); Backup();
myArray = new TDataStd_HLabelArray1(lower, upper);
if (upper >= lower)
myArray = new TDataStd_HLabelArray1(lower, upper);
} }
//======================================================================= //=======================================================================
@ -130,9 +129,39 @@ const Handle(TDataStd_HLabelArray1)& TDataStd_ReferenceArray::InternalArray () c
//function : SetInternalArray //function : SetInternalArray
//purpose : //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));
} }
//======================================================================= //=======================================================================