diff --git a/src/SMESHFiltersSelection/SMESH_LogicalFilter.cxx b/src/SMESHFiltersSelection/SMESH_LogicalFilter.cxx index 8da846f03..b05c2f413 100644 --- a/src/SMESHFiltersSelection/SMESH_LogicalFilter.cxx +++ b/src/SMESHFiltersSelection/SMESH_LogicalFilter.cxx @@ -30,7 +30,9 @@ // Purpose : Constructor //======================================================================= SMESH_LogicalFilter::SMESH_LogicalFilter (const QList& theFilters, - const int theLogOp) + const int theLogOp, + bool takeOwnership) + : myOwnership( takeOwnership ) { setFilters(theFilters); setOperation(theLogOp); @@ -42,6 +44,7 @@ SMESH_LogicalFilter::SMESH_LogicalFilter (const QList& th //======================================================================= SMESH_LogicalFilter::~SMESH_LogicalFilter() { + deleteFilters(); } //======================================================================= @@ -70,6 +73,7 @@ bool SMESH_LogicalFilter::isOk (const SUIT_DataOwner* owner) const //======================================================================= void SMESH_LogicalFilter::setFilters (const QList& theFilters) { + deleteFilters(); myFilters = theFilters; } @@ -99,3 +103,18 @@ int SMESH_LogicalFilter::getOperation() const { return myOperation; } +//================================================================================ +/*! + * \brief Deletes filters if has an ownership + */ +//================================================================================ + +void SMESH_LogicalFilter::deleteFilters() +{ + if ( myOwnership ) + { + SUIT_SelectionFilter* filter; + foreach( filter, myFilters ) + delete filter; + } +} diff --git a/src/SMESHFiltersSelection/SMESH_LogicalFilter.hxx b/src/SMESHFiltersSelection/SMESH_LogicalFilter.hxx index d1c2243b3..79217bae4 100644 --- a/src/SMESHFiltersSelection/SMESH_LogicalFilter.hxx +++ b/src/SMESHFiltersSelection/SMESH_LogicalFilter.hxx @@ -38,7 +38,7 @@ class SMESHFILTERSSELECTION_EXPORT SMESH_LogicalFilter : public SUIT_SelectionFi enum { LO_OR, LO_AND, LO_NOT, LO_UNDEFINED }; public: - SMESH_LogicalFilter( const QList&, const int ); + SMESH_LogicalFilter( const QList&, const int, bool takeOwnership=false ); virtual ~SMESH_LogicalFilter(); virtual bool isOk (const SUIT_DataOwner*) const; @@ -48,9 +48,13 @@ class SMESHFILTERSSELECTION_EXPORT SMESH_LogicalFilter : public SUIT_SelectionFi const QList getFilters() const; int getOperation() const; +private: + void deleteFilters(); + private: QList myFilters; int myOperation; + bool myOwnership; }; #endif