From: apo Date: Tue, 11 Oct 2005 06:04:01 +0000 (+0000) Subject: Improve memory management X-Git-Tag: BR-D5-38-2003_D2005-12-10~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4b520750d05018d8ac79adcbcc135f6885658256;p=modules%2Fgui.git Improve memory management --- 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*