From d5bf6747e1c71cec6adb569fe3200db8daec97cf Mon Sep 17 00:00:00 2001 From: apo Date: Mon, 17 Oct 2005 07:03:13 +0000 Subject: [PATCH] Fix on Bug GVIEW10305 Sigsegv after closing document Now, myRemoveActorsFromRendererSignal is called before VISU::Prs3d destruction --- src/OBJECT/VISU_Actor.cxx | 55 +++++++++++++++++++++------------- src/OBJECT/VISU_Actor.h | 1 + src/OBJECT/VISU_ActorFactory.h | 8 ++++- 3 files changed, 42 insertions(+), 22 deletions(-) diff --git a/src/OBJECT/VISU_Actor.cxx b/src/OBJECT/VISU_Actor.cxx index d52ead3f..90c4e50c 100644 --- a/src/OBJECT/VISU_Actor.cxx +++ b/src/OBJECT/VISU_Actor.cxx @@ -72,6 +72,7 @@ static int MYDEBUG = 1; static int MYDEBUG = 0; #endif +//#define ENABLE_ANNOTATION //---------------------------------------------------------------------------- vtkStandardNewMacro(VISU_Actor); @@ -100,9 +101,10 @@ VISU_Actor SetShrinkFactor(); myAnnotationMapper->Delete(); - myAnnotationActor->Delete(); myAnnotationActor->SetMapper(myAnnotationMapper.GetPointer()); - myAnnotationActor.GetPointer()->SetVisibility(0); + + myAnnotationActor->Delete(); + myAnnotationActor->SetVisibility(0); } //---------------------------------------------------------------------------- @@ -176,6 +178,16 @@ void VISU_Actor ::SetFactory(VISU::TActorFactory* theActorFactory) { + using namespace VISU; + + if(myActorFactory == theActorFactory) + return; + + if(theActorFactory) + myDestroySignal.connect(boost::bind(&TActorFactory::RemoveActor, + theActorFactory, + _1)); + myActorFactory = theActorFactory; } @@ -375,7 +387,7 @@ VISU_Actor { theRenderer->RemoveActor(myAnnotationActor.GetPointer()); Superclass::RemoveFromRender(theRenderer); - myActorFactory->RemoveActor(this); + myDestroySignal(this); } //---------------------------------------------------------------------------- @@ -490,6 +502,9 @@ VISU_Actor theInteractorStyle, theSelectionEvent, theIsHighlight); +#ifndef ENABLE_ANNOTATION + return aRet; +#endif // myAnnotationActor->SetVisibility(0); if(theIsHighlight){ @@ -532,7 +547,6 @@ VISU_Actor myAnnotationMapper->SetInput(aString.c_str()); myAnnotationActor->SetVisibility(1); - return true; } } @@ -553,25 +567,24 @@ VISU_Actor if(aVtkId >= 0 && theSelector->IsValid(this,aVtkId,true) && hasIO()){ vtkIdType anObjId = GetNodeObjId( aVtkId ); if(float* aCoord = GetNodeCoord(anObjId)){ - // Display coordinates - float aWorldCoord[4] = {aCoord[0], aCoord[1], aCoord[2], 1.0}; - aRenderer->SetWorldPoint(aWorldCoord); - aRenderer->WorldToDisplay(); - float aSelectionPoint[3]; - aRenderer->GetDisplayPoint(aSelectionPoint); - myAnnotationActor->SetPosition(aSelectionPoint); - // - // To prepare the annotation text - std::ostringstream aStr; - aStr<<"Node ID: "<< anObjId; - std::string aString = aStr.str(); - myAnnotationMapper->SetInput(aString.c_str()); - - myAnnotationActor->SetVisibility(1); + // Display coordinates + float aWorldCoord[4] = {aCoord[0], aCoord[1], aCoord[2], 1.0}; + aRenderer->SetWorldPoint(aWorldCoord); + aRenderer->WorldToDisplay(); + float aSelectionPoint[3]; + aRenderer->GetDisplayPoint(aSelectionPoint); + myAnnotationActor->SetPosition(aSelectionPoint); + // + // To prepare the annotation text + std::ostringstream aStr; + aStr<<"Node ID: "<< anObjId; + std::string aString = aStr.str(); + myAnnotationMapper->SetInput(aString.c_str()); - return true; - } + myAnnotationActor->SetVisibility(1); + return true; } + } break; } case EdgeOfCellSelection: diff --git a/src/OBJECT/VISU_Actor.h b/src/OBJECT/VISU_Actor.h index 75cfea0f..8a6c5de0 100644 --- a/src/OBJECT/VISU_Actor.h +++ b/src/OBJECT/VISU_Actor.h @@ -242,6 +242,7 @@ class VTKOCC_EXPORT VISU_Actor : vtkSmartPointer myMapper; VISU::TActorFactory* myActorFactory; + boost::signal1 myDestroySignal; vtkSmartPointer myShrinkFilter; bool myIsShrinkable; diff --git a/src/OBJECT/VISU_ActorFactory.h b/src/OBJECT/VISU_ActorFactory.h index 2cda6668..d594f5b8 100644 --- a/src/OBJECT/VISU_ActorFactory.h +++ b/src/OBJECT/VISU_ActorFactory.h @@ -29,13 +29,19 @@ #ifndef VISU_ACTOR_FACTORY_H #define VISU_ACTOR_FACTORY_H +#include + class VISU_Actor; //---------------------------------------------------------------------------- namespace VISU { - struct TActorFactory + struct TActorFactory: public virtual boost::bsignals::trackable { + virtual + ~TActorFactory() + {} + virtual void UpdateActor(VISU_Actor* theActor) = 0; -- 2.39.2