1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-05-16 10:54:53 +03:00

0022788: Exception during closing of document due to corrupted memory

This commit is contained in:
GKA 2011-11-11 16:04:04 +00:00 committed by bugmaster
parent 0ddd904c6a
commit 997cf5f22c
2 changed files with 51 additions and 41 deletions

View File

@ -192,27 +192,31 @@ static void RemoveNode(Standard_Boolean MapExist ,
if (pos->FirstUse() == N) { if (pos->FirstUse() == N) {
TNaming_Node* nextOld = N->nextSameOld; TNaming_Node* nextOld = N->nextSameOld;
if (nextOld != 0L) if (nextOld != 0L)
pos->FirstUse(nextOld); pos->FirstUse(nextOld);
else else {
// le shape disparait // le shape disparait
if (MapExist){ if (MapExist)
M.UnBind(pos->Shape()); M.UnBind(pos->Shape());
#ifdef BUC60921 //#ifdef BUC60921
N->myOld = 0L; N->myOld = 0L;
if(pos != N->myNew) if(pos != N->myNew)
delete pos; {
#endif delete pos;
} pos = 0L;
}
//#endif
}
} }
else { else {
TNaming_Node* pdn = pos->FirstUse(); TNaming_Node* pdn = pos->FirstUse();
while (pdn != 0L) { while (pdn != 0L) {
if (pdn->NextSameShape(pos) == N) {
if (pdn->myOld == pos) pdn->nextSameOld = N->nextSameOld; if (pdn->NextSameShape(pos) == N) {
else pdn->nextSameNew = N->nextSameOld; if (pdn->myOld == pos) pdn->nextSameOld = N->nextSameOld;
break; else pdn->nextSameNew = N->nextSameOld;
} break;
pdn = pdn->NextSameShape(pos); }
pdn = pdn->NextSameShape(pos);
} }
} }
} }
@ -222,26 +226,30 @@ static void RemoveNode(Standard_Boolean MapExist ,
if (pns->FirstUse() == N) { if (pns->FirstUse() == N) {
TNaming_Node* nextNew = N->nextSameNew; TNaming_Node* nextNew = N->nextSameNew;
if (nextNew != 0L) if (nextNew != 0L)
pns->FirstUse(nextNew); pns->FirstUse(nextNew);
else else
// le shape disparait {
if (MapExist) { // le shape disparait
M.UnBind(pns->Shape()); if (MapExist)
#ifdef BUC60921 M.UnBind(pns->Shape());
N->myNew = 0L;
delete pns; pns->FirstUse(0L);
#endif delete pns;
} pns = 0L;
N->myNew = 0L;
}
} }
else { else {
TNaming_Node* pdn = pns->FirstUse(); TNaming_Node* pdn = pns->FirstUse();
while (pdn != 0L) { while (pdn != 0L) {
if (pdn->NextSameShape(pns) == N) { if (pdn->NextSameShape(pns) == N) {
if (pdn->myOld == pns) pdn->nextSameOld = N->nextSameNew; if (pdn->myOld == pns) pdn->nextSameOld = N->nextSameNew;
else pdn->nextSameNew = N->nextSameNew; else pdn->nextSameNew = N->nextSameNew;
break; break;
} }
pdn = pdn->NextSameShape(pns); pdn = pdn->NextSameShape(pns);
} }
} }
} }
@ -282,8 +290,11 @@ void TNaming_NamedShape::Clear()
while (p != 0L) { while (p != 0L) {
q = p; q = p;
p = p->nextSameAttribute; p = p->nextSameAttribute;
delete q; if( q !=0L)
q = 0L; {
delete q;
q = 0L;
}
} }
myNode = 0L; myNode = 0L;
@ -347,8 +358,11 @@ Standard_Boolean TNaming_NamedShape::AfterUndo
while (p != 0L) { while (p != 0L) {
q = p; q = p;
p = p->nextSameAttribute; p = p->nextSameAttribute;
delete q; if(q != 0L)
q = 0L; {
delete q;
q = 0L;
}
} }
myNode = 0L; myNode = 0L;

View File

@ -9,7 +9,7 @@
#include <TDF_DeltaOnAddition.hxx> #include <TDF_DeltaOnAddition.hxx>
#include <TNaming_DataMapIteratorOfDataMapOfShapePtrRefShape.hxx> #include <TNaming_DataMapIteratorOfDataMapOfShapePtrRefShape.hxx>
#include <TNaming_RefShape.hxx> #include <TNaming_RefShape.hxx>
#include <TNaming_PtrNode.hxx>
#define BUC60862 #define BUC60862
#ifdef BUC60862 #ifdef BUC60862
@ -46,10 +46,6 @@ TNaming_UsedShapes::TNaming_UsedShapes()
void TNaming_UsedShapes::Destroy() void TNaming_UsedShapes::Destroy()
{ {
TNaming_DataMapIteratorOfDataMapOfShapePtrRefShape itr(myMap);
for (; itr.More(); itr.Next()) {
if(itr.Value() != NULL) delete itr.Value(); // <== szy: removed "//"
}
myMap.Clear(); myMap.Clear();
} }