X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESH%2FSMESH_Gen.cxx;h=bd5654c89588eb1bd05ddde3ae963e978e7cd8eb;hp=7388a0095d1f74cc4b5252a6c735a0922da41a57;hb=e2ed82ab76826fe71cb635add1926e389c2fff9f;hpb=41b3e4433388f439856c3b0bb3725e9c81179c24 diff --git a/src/SMESH/SMESH_Gen.cxx b/src/SMESH/SMESH_Gen.cxx index 7388a0095..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; + } } //============================================================================= @@ -1168,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 */ //=============================================================================