mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-01-12 09:40:35 +05:00
To avoid memory leaks
This commit is contained in:
parent
bcbdd40a30
commit
5ff23c3748
@ -78,6 +78,10 @@ SMESH_PreviewActorsCollection
|
||||
if (myRenderer)
|
||||
RemoveFromRender(myRenderer);
|
||||
|
||||
QMap<int, GEOM_Actor*>::iterator iter = myMapOfActors.begin();
|
||||
for ( ; iter != myMapOfActors.end(); ++iter )
|
||||
if ( GEOM_Actor* anActor = iter.value() )
|
||||
anActor->Delete();
|
||||
myMapOfActors.clear();
|
||||
}
|
||||
|
||||
@ -99,26 +103,26 @@ bool SMESH_PreviewActorsCollection::Init( const TopoDS_Shape& theShape, TopAbs_S
|
||||
TopExp_Explorer exp( theShape, theType );
|
||||
for ( ; exp.More(); exp.Next() ) {
|
||||
int index = myMapOfShapes.FindIndex( exp.Current() );
|
||||
if ( index ) {
|
||||
if ( index && !myMapOfActors.contains( index ) ) {
|
||||
// create actor if the index is present
|
||||
if ( GEOM_Actor* anActor = createActor( exp.Current() )) {
|
||||
// Create new entry for actor
|
||||
QString aString = theEntry;
|
||||
aString += QString("_%1").arg( index ); // add index to actor entry
|
||||
// Create new entry for actor
|
||||
QString aString = theEntry;
|
||||
aString += QString("_%1").arg( index ); // add index to actor entry
|
||||
|
||||
// Create interactive object
|
||||
Handle( SALOME_InteractiveObject ) anIO = new SALOME_InteractiveObject();
|
||||
anIO->setEntry( aString.toLatin1().constData() );
|
||||
// Create interactive object
|
||||
Handle( SALOME_InteractiveObject ) anIO = new SALOME_InteractiveObject();
|
||||
anIO->setEntry( aString.toLatin1().constData() );
|
||||
|
||||
// Init Actor
|
||||
anActor->SetVectorMode( true );
|
||||
anActor->setIO( anIO );
|
||||
anActor->SetSelector( mySelector );
|
||||
anActor->SetPickable( true );
|
||||
anActor->SetResolveCoincidentTopology( true );
|
||||
// Init Actor
|
||||
anActor->SetVectorMode( true );
|
||||
anActor->setIO( anIO );
|
||||
anActor->SetSelector( mySelector );
|
||||
anActor->SetPickable( true );
|
||||
anActor->SetResolveCoincidentTopology( true );
|
||||
|
||||
// Add Actor to the Actors Map
|
||||
myMapOfActors.insert(index, anActor);
|
||||
// Add Actor to the Actors Map
|
||||
myMapOfActors.insert(index, anActor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -80,7 +80,8 @@
|
||||
|
||||
StdMeshersGUI_SubShapeSelectorWdg
|
||||
::StdMeshersGUI_SubShapeSelectorWdg( QWidget * parent ):
|
||||
QWidget( parent )
|
||||
QWidget( parent ),
|
||||
myPreviewActor( 0 )
|
||||
{
|
||||
QPixmap image0( SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap( "SMESH", tr( "ICON_SELECT" ) ) );
|
||||
|
||||
@ -118,14 +119,17 @@ StdMeshersGUI_SubShapeSelectorWdg
|
||||
StdMeshersGUI_SubShapeSelectorWdg::~StdMeshersGUI_SubShapeSelectorWdg()
|
||||
{
|
||||
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) {
|
||||
myPreviewActor->RemoveFromRender( myRenderer );
|
||||
aViewWindow->Repaint();
|
||||
if ( myPreviewActor ) {
|
||||
myPreviewActor->RemoveFromRender( myRenderer );
|
||||
aViewWindow->Repaint();
|
||||
|
||||
delete myPreviewActor;
|
||||
myPreviewActor = 0;
|
||||
}
|
||||
}
|
||||
myEntry = "";
|
||||
myParamValue = "";
|
||||
myMainShape.Nullify();
|
||||
|
||||
delete myPreviewActor;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
@ -164,6 +168,9 @@ void StdMeshersGUI_SubShapeSelectorWdg::init()
|
||||
|
||||
void StdMeshersGUI_SubShapeSelectorWdg::showPreview( bool visible)
|
||||
{
|
||||
if ( !myPreviewActor )
|
||||
return;
|
||||
|
||||
if ( myIsShown != visible ) {
|
||||
myPreviewActor->SetShown( visible );
|
||||
|
||||
@ -180,6 +187,9 @@ void StdMeshersGUI_SubShapeSelectorWdg::showPreview( bool visible)
|
||||
//=================================================================================
|
||||
void StdMeshersGUI_SubShapeSelectorWdg::SelectionIntoArgument()
|
||||
{
|
||||
if ( !myPreviewActor )
|
||||
return;
|
||||
|
||||
mySelectedIDs.clear();
|
||||
|
||||
// get selected mesh
|
||||
@ -309,6 +319,9 @@ void StdMeshersGUI_SubShapeSelectorWdg::onRemove()
|
||||
//=================================================================================
|
||||
void StdMeshersGUI_SubShapeSelectorWdg::onListSelectionChanged()
|
||||
{
|
||||
if ( !myPreviewActor )
|
||||
return;
|
||||
|
||||
mySelectionMgr->clearSelected();
|
||||
TColStd_MapOfInteger aIndexes;
|
||||
QList<QListWidgetItem*> selItems = myListWidget->selectedItems();
|
||||
@ -345,7 +358,7 @@ void StdMeshersGUI_SubShapeSelectorWdg::updateState()
|
||||
myAddButton->setEnabled( state );
|
||||
myRemoveButton->setEnabled( state );
|
||||
|
||||
if (state = true) {
|
||||
if (state) {
|
||||
myPreviewActor = new SMESH_PreviewActorsCollection();
|
||||
myPreviewActor->SetSelector( mySelector );
|
||||
//myPreviewActor->Init( myMainShape, TopAbs_EDGE, myEntry );
|
||||
|
Loading…
Reference in New Issue
Block a user