X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESH%2FSMESH_Gen.cxx;h=bd5654c89588eb1bd05ddde3ae963e978e7cd8eb;hb=42c70284400c5b73aca9b9b8ffd91a035da25bf8;hp=7ca0a59fa14bf66169b75b1e78cd6a1cfd4d1c11;hpb=a1920ff31054e2c882bd94d4f3c04abe53980ce0;p=modules%2Fsmesh.git diff --git a/src/SMESH/SMESH_Gen.cxx b/src/SMESH/SMESH_Gen.cxx index 7ca0a59fa..bd5654c89 100644 --- a/src/SMESH/SMESH_Gen.cxx +++ b/src/SMESH/SMESH_Gen.cxx @@ -73,6 +73,19 @@ SMESH_Gen::SMESH_Gen() //vtkDebugLeaks::SetExitError(0); } +namespace +{ + // a structure used to nullify SMESH_Gen field of SMESH_Hypothesis, + // which is needed for SMESH_Hypothesis not deleted before ~SMESH_Gen() + struct _Hyp : public SMESH_Hypothesis + { + void NullifyGen() + { + _gen = 0; + } + }; +} + //============================================================================= /*! * Destructor @@ -84,9 +97,16 @@ SMESH_Gen::~SMESH_Gen() std::map < int, StudyContextStruct * >::iterator i_sc = _mapStudyContext.begin(); for ( ; i_sc != _mapStudyContext.end(); ++i_sc ) { - delete i_sc->second->myDocument; - delete i_sc->second; - } + StudyContextStruct* context = i_sc->second; + std::map < int, SMESH_Hypothesis * >::iterator i_hyp = context->mapHypothesis.begin(); + for ( ; i_hyp != context->mapHypothesis.end(); ++i_hyp ) + { + if ( _Hyp* h = static_cast< _Hyp*>( i_hyp->second )) + h->NullifyGen(); + } + delete context->myDocument; + delete context; + } } //============================================================================= @@ -586,7 +606,6 @@ bool SMESH_Gen::Evaluate(SMESH_Mesh & aMesh, ret = Evaluate( aMesh, aShape, aResMap, /*anUpward=*/true, aShapesId ); } - MESSAGE( "VSR - SMESH_Gen::Evaluate() finished, OK = " << ret); return ret; } @@ -1169,7 +1188,7 @@ int SMESH_Gen::GetShapeDim(const TopAbs_ShapeEnum & aShapeType) //============================================================================= /*! - * Genarate a new id unique withing this Gen + * Genarate a new id unique within this Gen */ //=============================================================================