From 4b520750d05018d8ac79adcbcc135f6885658256 Mon Sep 17 00:00:00 2001 From: apo Date: Tue, 11 Oct 2005 06:04:01 +0000 Subject: [PATCH] Improve memory management --- src/SVTK/SVTK_Renderer.cxx | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/SVTK/SVTK_Renderer.cxx b/src/SVTK/SVTK_Renderer.cxx index b69620b6b..864ce5967 100644 --- a/src/SVTK/SVTK_Renderer.cxx +++ b/src/SVTK/SVTK_Renderer.cxx @@ -128,9 +128,12 @@ SVTK_Renderer vtkActorCollection* anActors = GetDevice()->GetActors(); anActors->InitTraversal(); while(vtkActor* anAct = anActors->GetNextActor()){ - if(VTKViewer_Actor* anActor = dynamic_cast(anAct)){ - anActor->RemoveFromRender(GetDevice()); + if(SALOME_Actor* anActor = dynamic_cast(anAct)){ + // Order of the calls are important because VTKViewer_Actor::RemoveFromRender + // can leads do destruction of the actor anActor->SetTransform(NULL); + anActor->SetInteractor(NULL); + anActor->RemoveFromRender(GetDevice()); } } } @@ -178,20 +181,24 @@ void SVTK_Renderer ::AddActor(VTKViewer_Actor* theActor) { - if(SALOME_Actor* anActor = dynamic_cast(theActor)) + if(SALOME_Actor* anActor = dynamic_cast(theActor)){ anActor->SetInteractor(myInteractor); - theActor->SetTransform(GetTransform()); - theActor->AddToRender(GetDevice()); - AdjustActors(); + anActor->SetTransform(GetTransform()); + anActor->AddToRender(GetDevice()); + AdjustActors(); + } } void SVTK_Renderer ::RemoveActor(VTKViewer_Actor* theActor) { - theActor->SetTransform(NULL); - theActor->RemoveFromRender(GetDevice()); - AdjustActors(); + if(SALOME_Actor* anActor = dynamic_cast(theActor)){ + anActor->SetInteractor(NULL); + anActor->SetTransform(NULL); + anActor->RemoveFromRender(GetDevice()); + AdjustActors(); + } } VTKViewer_Transform* -- 2.39.2