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

@ -193,20 +193,24 @@ static void RemoveNode(Standard_Boolean MapExist ,
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; delete pos;
#endif 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->NextSameShape(pos) == N) {
if (pdn->myOld == pos) pdn->nextSameOld = N->nextSameOld; if (pdn->myOld == pos) pdn->nextSameOld = N->nextSameOld;
else pdn->nextSameNew = N->nextSameOld; else pdn->nextSameNew = N->nextSameOld;
@ -224,13 +228,17 @@ static void RemoveNode(Standard_Boolean MapExist ,
if (nextNew != 0L) if (nextNew != 0L)
pns->FirstUse(nextNew); pns->FirstUse(nextNew);
else else
{
// le shape disparait // le shape disparait
if (MapExist) { if (MapExist)
M.UnBind(pns->Shape()); M.UnBind(pns->Shape());
#ifdef BUC60921
N->myNew = 0L; pns->FirstUse(0L);
delete pns; delete pns;
#endif pns = 0L;
N->myNew = 0L;
} }
} }
else { else {
@ -282,9 +290,12 @@ void TNaming_NamedShape::Clear()
while (p != 0L) { while (p != 0L) {
q = p; q = p;
p = p->nextSameAttribute; p = p->nextSameAttribute;
if( q !=0L)
{
delete q; delete q;
q = 0L; q = 0L;
} }
}
myNode = 0L; myNode = 0L;
} }
@ -347,9 +358,12 @@ Standard_Boolean TNaming_NamedShape::AfterUndo
while (p != 0L) { while (p != 0L) {
q = p; q = p;
p = p->nextSameAttribute; p = p->nextSameAttribute;
if(q != 0L)
{
delete q; delete q;
q = 0L; 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();
} }