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