From: jfa Date: Thu, 6 Apr 2006 08:12:40 +0000 (+0000) Subject: Fix bug 12109: SIGSEGV after trying to create sub-mesh in the second study. X-Git-Tag: T3_2_0b1_pre1~49 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=39e3ed0090af2a6caa77376b10e116d30ddcd037;p=modules%2Fsmesh.git Fix bug 12109: SIGSEGV after trying to create sub-mesh in the second study. --- diff --git a/src/SMESHGUI/SMESHGUI_SelectionOp.cxx b/src/SMESHGUI/SMESHGUI_SelectionOp.cxx index c03de45c1..2616fa69f 100644 --- a/src/SMESHGUI/SMESHGUI_SelectionOp.cxx +++ b/src/SMESHGUI/SMESHGUI_SelectionOp.cxx @@ -67,11 +67,7 @@ SMESHGUI_SelectionOp::SMESHGUI_SelectionOp( const Selection_Mode mode ) //================================================================================= SMESHGUI_SelectionOp::~SMESHGUI_SelectionOp() { - Filters::const_iterator anIt = myFilters.begin(), - aLast = myFilters.end(); - for( ; anIt!=aLast; anIt++ ) - if( anIt.data() ) - delete anIt.data(); + removeCustomFilters(); } //================================================================================= @@ -99,17 +95,21 @@ void SMESHGUI_SelectionOp::startOperation() // name : removeCustomFilters // purpose : //================================================================================= -void SMESHGUI_SelectionOp::removeCustomFilters() const +void SMESHGUI_SelectionOp::removeCustomFilters() { - LightApp_SelectionMgr* mgr = selectionMgr(); - if( !mgr ) - return; - - Filters::const_iterator anIt = myFilters.begin(), - aLast = myFilters.end(); - for( ; anIt!=aLast; anIt++ ) - if( anIt.data() ) - mgr->removeFilter( anIt.data() ); + if (myFilters.count() > 0) { + LightApp_SelectionMgr* mgr = selectionMgr(); + Filters::const_iterator anIt = myFilters.begin(), + aLast = myFilters.end(); + for (; anIt != aLast; anIt++) { + if (anIt.data()) { + if (mgr) mgr->removeFilter(anIt.data()); + delete anIt.data(); + } + } + + myFilters.clear(); + } } //================================================================================= @@ -195,9 +195,7 @@ void SMESHGUI_SelectionOp::onActivateObject( int id ) //================================================================================= void SMESHGUI_SelectionOp::onDeactivateObject( int id ) { - LightApp_SelectionMgr* mgr = selectionMgr(); - if( mgr && myFilters.contains( id ) && myFilters[ id ] ) - mgr->removeFilter( myFilters[ id ] ); + removeCustomFilters(); } //================================================================================= diff --git a/src/SMESHGUI/SMESHGUI_SelectionOp.h b/src/SMESHGUI/SMESHGUI_SelectionOp.h index bb1a05b66..e2075a1bb 100644 --- a/src/SMESHGUI/SMESHGUI_SelectionOp.h +++ b/src/SMESHGUI/SMESHGUI_SelectionOp.h @@ -90,7 +90,7 @@ protected: virtual SUIT_SelectionFilter* createFilter( const int ) const; //! Remove only filters set by this operation (they are in map myFilters ) - void removeCustomFilters() const; + void removeCustomFilters(); //! Return what selection mode is set in VTK viewer Selection_Mode selectionMode() const;