mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-04 18:06:22 +03:00
0025112: Undo of modification of the attribute TDataStd_IntPackedMap works wrong
Test case for issue #25112
This commit is contained in:
parent
5402ccdda6
commit
6d1dc3e82c
@ -1215,6 +1215,8 @@ Standard_Boolean TColStd_PackedMapOfInteger::IsSubset (const TColStd_PackedMapOf
|
||||
// Find the corresponding block in the 2nd map
|
||||
const TColStd_intMapNode * p2 =
|
||||
aData2 [HashCode (aKeyInt, nBuckets2)];
|
||||
if (!p2)
|
||||
return Standard_False;
|
||||
while (p2) {
|
||||
if ( p2->IsEqual(aKeyInt) ) {
|
||||
if ( p1->Data() & ~p2->Data() ) // at least one bit set in p1 is not set in p2
|
||||
|
@ -34,42 +34,38 @@ TDataStd_DeltaOnModificationOfIntPackedMap::TDataStd_DeltaOnModificationOfIntPac
|
||||
: TDF_DeltaOnModification(OldAtt)
|
||||
{
|
||||
Handle(TDataStd_IntPackedMap) CurrAtt;
|
||||
if (Label().FindAttribute(OldAtt->ID(),CurrAtt)) {
|
||||
{
|
||||
Handle(TColStd_HPackedMapOfInteger) aMap1, aMap2;
|
||||
aMap1 = OldAtt->GetHMap();
|
||||
aMap2 = CurrAtt->GetHMap();
|
||||
#ifdef DEB
|
||||
if(aMap1.IsNull())
|
||||
cout <<"DeltaOnModificationOfIntPackedMap:: Old Map is Null" <<endl;
|
||||
if(aMap2.IsNull())
|
||||
cout <<"DeltaOnModificationOfIntPackedMap:: Current Map is Null" <<endl;
|
||||
if (Label().FindAttribute(OldAtt->ID(), CurrAtt))
|
||||
{
|
||||
Handle(TColStd_HPackedMapOfInteger) aMap1, aMap2;
|
||||
aMap1 = OldAtt->GetHMap();
|
||||
aMap2 = CurrAtt->GetHMap();
|
||||
#ifdef DEB_disable
|
||||
if (aMap1.IsNull())
|
||||
cout <<"DeltaOnModificationOfIntPackedMap:: Old Map is Null" <<endl;
|
||||
if (aMap2.IsNull())
|
||||
cout <<"DeltaOnModificationOfIntPackedMap:: Current Map is Null" <<endl;
|
||||
#endif
|
||||
|
||||
if(aMap1.IsNull() || aMap2.IsNull()) return;
|
||||
if(aMap1 != aMap2) {
|
||||
if(!aMap1->Map().HasIntersection(aMap2->Map()))
|
||||
return; // no intersection: use full-scale backup
|
||||
|
||||
if(aMap1->Map().IsSubset(aMap2->Map())) {
|
||||
myDeletion = new TColStd_HPackedMapOfInteger();
|
||||
myDeletion->ChangeMap().Subtraction(aMap2->Map(), aMap1->Map());
|
||||
} else if(aMap2->Map().IsSubset(aMap1->Map())) {
|
||||
myAddition = new TColStd_HPackedMapOfInteger();
|
||||
myAddition->ChangeMap().Subtraction(aMap1->Map(), aMap2->Map());
|
||||
} else {
|
||||
myAddition = new TColStd_HPackedMapOfInteger();
|
||||
myAddition->ChangeMap().Subtraction(aMap1->Map(), aMap2->Map());
|
||||
myDeletion = new TColStd_HPackedMapOfInteger();
|
||||
myDeletion->ChangeMap().Subtraction(aMap2->Map(), aMap1->Map());
|
||||
}
|
||||
if (aMap1.IsNull() || aMap2.IsNull()) return;
|
||||
if (aMap1 != aMap2) {
|
||||
const TColStd_PackedMapOfInteger& map1 = aMap1->Map();
|
||||
const TColStd_PackedMapOfInteger& map2 = aMap2->Map();
|
||||
if (map1.IsSubset(map2)) {
|
||||
myDeletion = new TColStd_HPackedMapOfInteger();
|
||||
myDeletion->ChangeMap().Subtraction(map2, map1);
|
||||
} else if (map2.IsSubset(map1)) {
|
||||
myAddition = new TColStd_HPackedMapOfInteger();
|
||||
myAddition->ChangeMap().Subtraction(map1, map2);
|
||||
} else if (map1.HasIntersection(map2)) {
|
||||
myAddition = new TColStd_HPackedMapOfInteger();
|
||||
myAddition->ChangeMap().Subtraction(map1, map2);
|
||||
myDeletion = new TColStd_HPackedMapOfInteger();
|
||||
myDeletion->ChangeMap().Subtraction(map2, map1);
|
||||
} else {
|
||||
myAddition = new TColStd_HPackedMapOfInteger(map1);
|
||||
myDeletion = new TColStd_HPackedMapOfInteger(map2);
|
||||
}
|
||||
}
|
||||
OldAtt->RemoveMap();
|
||||
#ifdef DEB
|
||||
if(OldAtt->GetHMap().IsNull())
|
||||
cout << "BackUp Arr is Nullified" << endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -109,23 +105,21 @@ void TDataStd_DeltaOnModificationOfIntPackedMap::Apply()
|
||||
|
||||
|
||||
Handle(TColStd_HPackedMapOfInteger) IntMap = aCurAtt->GetHMap();
|
||||
if(IntMap.IsNull()) return;
|
||||
if (IntMap.IsNull()) return;
|
||||
|
||||
if(myDeletion.IsNull() && myAddition.IsNull())
|
||||
if (myDeletion.IsNull() && myAddition.IsNull())
|
||||
return;
|
||||
else {
|
||||
if(!myDeletion.IsNull()) {
|
||||
|
||||
if(myDeletion->Map().Extent())
|
||||
IntMap->ChangeMap().Subtract(myDeletion->Map());
|
||||
}
|
||||
if(!myAddition.IsNull()) {
|
||||
if(myAddition->Map().Extent())
|
||||
IntMap->ChangeMap().Unite(myAddition->Map());
|
||||
}
|
||||
|
||||
if (!myDeletion.IsNull()) {
|
||||
if (myDeletion->Map().Extent())
|
||||
IntMap->ChangeMap().Subtract(myDeletion->Map());
|
||||
}
|
||||
if (!myAddition.IsNull()) {
|
||||
if (myAddition->Map().Extent())
|
||||
IntMap->ChangeMap().Unite(myAddition->Map());
|
||||
}
|
||||
|
||||
#ifdef DEB
|
||||
#ifdef DEB_disable
|
||||
cout << " << Map Dump after Delta Apply >>" <<endl;
|
||||
Handle(TColStd_HPackedMapOfInteger) aIntMap = aCurAtt->GetHMap();
|
||||
TColStd_MapIteratorOfPackedMapOfInteger it(aIntMap->Map());
|
||||
@ -134,5 +128,3 @@ void TDataStd_DeltaOnModificationOfIntPackedMap::Apply()
|
||||
cout <<endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
27
tests/bugs/caf/bug25112
Normal file
27
tests/bugs/caf/bug25112
Normal file
@ -0,0 +1,27 @@
|
||||
puts "==========="
|
||||
puts "OCC25112"
|
||||
puts "==========="
|
||||
puts ""
|
||||
###########################################################################
|
||||
# Undo of modification of the attribute TDataStd_IntPackedMap works wrong
|
||||
###########################################################################
|
||||
|
||||
NewDocument D
|
||||
UndoLimit D 10
|
||||
SetIntPackedMap D 0:1 1 319
|
||||
puts "initial: [GetIntPackedMap D 0:1]"
|
||||
|
||||
OpenCommand D
|
||||
ChangeIntPackedMap_Add D 0:1 344
|
||||
ChangeIntPackedMap_Rem D 0:1 319
|
||||
CommitCommand D
|
||||
puts "after changes: [GetIntPackedMap D 0:1]"
|
||||
|
||||
Undo D
|
||||
|
||||
set map [GetIntPackedMap D 0:1]
|
||||
puts "after undo: $map"
|
||||
|
||||
if {$map != "319"} {
|
||||
puts "ERROR: OCC25112 is reproduced. Expected map content is 319"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user