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