mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-03 17:56:21 +03:00
0018170: Modeling Data - crash in TopExp_Explorer::Init if Clear was called after empty constructor
TopExp_Explorer::Clear() now sets myTop=-1 with align to TopExp_Explorer::Init() logic.
This commit is contained in:
parent
f26ee38f2a
commit
a1ae05e173
@ -33,49 +33,49 @@ static const Standard_Integer theStackSize = 20;
|
||||
|
||||
//=======================================================================
|
||||
//function : TopExp_Explorer
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TopExp_Explorer::TopExp_Explorer() :
|
||||
myStack(0L),myTop(-1),hasMore(Standard_False)
|
||||
TopExp_Explorer::TopExp_Explorer()
|
||||
: myStack (0L),
|
||||
myTop (-1),
|
||||
mySizeOfStack (theStackSize),
|
||||
toFind (TopAbs_SHAPE),
|
||||
toAvoid (TopAbs_SHAPE),
|
||||
hasMore (Standard_False)
|
||||
{
|
||||
myStack = (TopoDS_Iterator*)Standard::Allocate(theStackSize*sizeof(TopoDS_Iterator));
|
||||
mySizeOfStack = theStackSize;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : TopExp_Explorer
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TopExp_Explorer::TopExp_Explorer(const TopoDS_Shape& S,
|
||||
const TopAbs_ShapeEnum ToFind,
|
||||
const TopAbs_ShapeEnum ToAvoid):
|
||||
myStack(0L),myTop(-1),hasMore(Standard_False)
|
||||
|
||||
TopExp_Explorer::TopExp_Explorer (const TopoDS_Shape& theS,
|
||||
const TopAbs_ShapeEnum theToFind,
|
||||
const TopAbs_ShapeEnum theToAvoid)
|
||||
: myStack (0L),
|
||||
myTop (-1),
|
||||
mySizeOfStack (theStackSize),
|
||||
toFind (theToFind),
|
||||
toAvoid (theToAvoid),
|
||||
hasMore (Standard_False)
|
||||
{
|
||||
myStack = (TopoDS_Iterator*)Standard::Allocate(theStackSize*sizeof(TopoDS_Iterator));
|
||||
mySizeOfStack = theStackSize;
|
||||
Init(S,ToFind,ToAvoid);
|
||||
|
||||
Init (theS, theToFind, theToAvoid);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void TopExp_Explorer::Init(const TopoDS_Shape& S,
|
||||
const TopAbs_ShapeEnum ToFind,
|
||||
const TopAbs_ShapeEnum ToAvoid)
|
||||
{
|
||||
if(myTop >=0) {
|
||||
for(int i=0;i<= myTop; i++)
|
||||
myStack[i].~TopoDS_Iterator();
|
||||
}
|
||||
|
||||
myTop = -1;
|
||||
Clear();
|
||||
|
||||
myShape = S;
|
||||
toFind = ToFind;
|
||||
toAvoid = ToAvoid;
|
||||
@ -131,18 +131,11 @@ const TopoDS_Shape& TopExp_Explorer::Current()const
|
||||
return myShape;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Next
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4291) // to avoid warning when using new(buffer) syntax
|
||||
#endif
|
||||
|
||||
void TopExp_Explorer::Next()
|
||||
void TopExp_Explorer::Next()
|
||||
{
|
||||
Standard_Integer NewSize;
|
||||
TopoDS_Shape ShapTop;
|
||||
@ -219,28 +212,40 @@ void TopExp_Explorer::Next()
|
||||
hasMore = Standard_False;
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
//=======================================================================
|
||||
//function : ReInit
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void TopExp_Explorer::ReInit()
|
||||
void TopExp_Explorer::ReInit()
|
||||
{
|
||||
Init(myShape,toFind,toAvoid);
|
||||
}
|
||||
|
||||
void TopExp_Explorer::Destroy()
|
||||
//=======================================================================
|
||||
//function : ~TopExp_Explorer
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
TopExp_Explorer::~TopExp_Explorer()
|
||||
{
|
||||
if (myStack)
|
||||
{
|
||||
for(int i=0;i<= myTop; i++)myStack[i].~TopoDS_Iterator();
|
||||
Standard::Free(myStack);
|
||||
}
|
||||
Clear();
|
||||
if (myStack)
|
||||
{
|
||||
Standard::Free(myStack);
|
||||
}
|
||||
mySizeOfStack = 0;
|
||||
myStack = 0L;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Clear
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void TopExp_Explorer::Clear()
|
||||
{
|
||||
hasMore = Standard_False;
|
||||
for (int i = 0; i <= myTop; ++i)
|
||||
{
|
||||
myStack[i].~TopoDS_Iterator();
|
||||
}
|
||||
myTop = -1;
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
#define _TopExp_Explorer_HeaderFile
|
||||
|
||||
#include <TopExp_Stack.hxx>
|
||||
#include <TopoDS_Iterator.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
|
||||
//! An Explorer is a Tool to visit a Topological Data
|
||||
@ -136,39 +137,21 @@ public:
|
||||
|
||||
//! Clears the content of the explorer. It will return
|
||||
//! False on More().
|
||||
void Clear();
|
||||
|
||||
Standard_EXPORT void Destroy();
|
||||
~TopExp_Explorer()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
Standard_EXPORT void Clear();
|
||||
|
||||
//! Destructor.
|
||||
Standard_EXPORT ~TopExp_Explorer();
|
||||
|
||||
private:
|
||||
|
||||
TopExp_Stack myStack;
|
||||
TopoDS_Shape myShape;
|
||||
Standard_Integer myTop;
|
||||
Standard_Integer mySizeOfStack;
|
||||
TopoDS_Shape myShape;
|
||||
Standard_Boolean hasMore;
|
||||
TopAbs_ShapeEnum toFind;
|
||||
TopAbs_ShapeEnum toAvoid;
|
||||
Standard_Boolean hasMore;
|
||||
|
||||
};
|
||||
|
||||
#include <TopoDS_Iterator.hxx>
|
||||
|
||||
inline void TopExp_Explorer::Clear()
|
||||
{
|
||||
hasMore = Standard_False;
|
||||
if (myTop > 0)
|
||||
{
|
||||
for (int i = 1; i <= myTop; i++)
|
||||
{
|
||||
myStack[i].~TopoDS_Iterator();
|
||||
}
|
||||
}
|
||||
myTop = 0;
|
||||
}
|
||||
|
||||
#endif // _TopExp_Explorer_HeaderFile
|
||||
|
Loading…
x
Reference in New Issue
Block a user