From 07589de92eb5d8e7d4e3bfde8b26f0d69251acf0 Mon Sep 17 00:00:00 2001 From: eap Date: Thu, 10 Sep 2015 20:50:31 +0300 Subject: [PATCH] IPAL52867: Crash at attempt to create group by 'Color of Group' filter --- src/Controls/SMESH_Controls.cxx | 21 +++++++----- src/SMESH_I/SMESH_Filter_i.cxx | 60 ++++++++++++++++----------------- src/SMESH_SWIG/smeshBuilder.py | 12 +++++++ 3 files changed, 55 insertions(+), 38 deletions(-) diff --git a/src/Controls/SMESH_Controls.cxx b/src/Controls/SMESH_Controls.cxx index 65ff05b9b..769096df4 100644 --- a/src/Controls/SMESH_Controls.cxx +++ b/src/Controls/SMESH_Controls.cxx @@ -31,9 +31,10 @@ #include "SMDS_QuadraticFaceOfNodes.hxx" #include "SMDS_VolumeTool.hxx" #include "SMESHDS_GroupBase.hxx" +#include "SMESHDS_GroupOnFilter.hxx" #include "SMESHDS_Mesh.hxx" -#include "SMESH_OctreeNode.hxx" #include "SMESH_MeshAlgos.hxx" +#include "SMESH_OctreeNode.hxx" #include @@ -2650,7 +2651,7 @@ GroupColor::GroupColor() bool GroupColor::IsSatisfy( long theId ) { - return (myIDs.find( theId ) != myIDs.end()); + return myIDs.count( theId ); } void GroupColor::SetType( SMDSAbs_ElementType theType ) @@ -2676,7 +2677,7 @@ static bool isEqual( const Quantity_Color& theColor1, void GroupColor::SetMesh( const SMDS_Mesh* theMesh ) { myIDs.clear(); - + const SMESHDS_Mesh* aMesh = dynamic_cast(theMesh); if ( !aMesh ) return; @@ -2684,20 +2685,24 @@ void GroupColor::SetMesh( const SMDS_Mesh* theMesh ) int nbGrp = aMesh->GetNbGroups(); if ( !nbGrp ) return; - + // iterates on groups and find necessary elements ids const std::set& aGroups = aMesh->GetGroups(); set::const_iterator GrIt = aGroups.begin(); - for (; GrIt != aGroups.end(); GrIt++) { + for (; GrIt != aGroups.end(); GrIt++) + { SMESHDS_GroupBase* aGrp = (*GrIt); if ( !aGrp ) continue; // check type and color of group - if ( !isEqual( myColor, aGrp->GetColor() ) ) - continue; - if ( myType != SMDSAbs_All && myType != (SMDSAbs_ElementType)aGrp->GetType() ) + if ( !isEqual( myColor, aGrp->GetColor() )) continue; + // IPAL52867 (prevent infinite recursion via GroupOnFilter) + if ( SMESHDS_GroupOnFilter * gof = dynamic_cast< SMESHDS_GroupOnFilter* >( aGrp )) + if ( gof->GetPredicate().get() == this ) + continue; + SMDSAbs_ElementType aGrpElType = (SMDSAbs_ElementType)aGrp->GetType(); if ( myType == aGrpElType || (myType == SMDSAbs_All && aGrpElType != SMDSAbs_Node) ) { // add elements IDS into control diff --git a/src/SMESH_I/SMESH_Filter_i.cxx b/src/SMESH_I/SMESH_Filter_i.cxx index 46a46b18d..94c76ec3d 100644 --- a/src/SMESH_I/SMESH_Filter_i.cxx +++ b/src/SMESH_I/SMESH_Filter_i.cxx @@ -839,8 +839,8 @@ BelongToGeom_i::BelongToGeom_i() BelongToGeom_i::~BelongToGeom_i() { - delete myShapeName; - delete myShapeID; + CORBA::string_free( myShapeName ); + CORBA::string_free( myShapeID ); } void BelongToGeom_i::SetGeom( GEOM::GEOM_Object_ptr theGeom ) @@ -872,18 +872,18 @@ FunctorType BelongToGeom_i::GetFunctorType() void BelongToGeom_i::SetShapeName( const char* theName ) { - delete myShapeName; - myShapeName = strdup( theName ); + CORBA::string_free( myShapeName ); + myShapeName = CORBA::string_dup( theName ); myBelongToGeomPtr->SetGeom( getShapeByName( myShapeName ) ); TPythonDump()<SetSurface( getShapeByName( myShapeName ), (SMDSAbs_ElementType)theType ); TPythonDump()<SetGeom( getShapeByName( myShapeName ) ); TPythonDump()<_this(); @@ -3713,7 +3713,7 @@ FilterLibrary_i::FilterLibrary_i() FilterLibrary_i::~FilterLibrary_i() { - delete myFileName; + CORBA::string_free( myFileName ); //TPythonDump()<