]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Fix on Bug GVIEW10305
authorapo <apo@opencascade.com>
Mon, 17 Oct 2005 07:03:13 +0000 (07:03 +0000)
committerapo <apo@opencascade.com>
Mon, 17 Oct 2005 07:03:13 +0000 (07:03 +0000)
 Sigsegv after closing document
Now, myRemoveActorsFromRendererSignal is called before VISU::Prs3d destruction

src/OBJECT/VISU_Actor.cxx
src/OBJECT/VISU_Actor.h
src/OBJECT/VISU_ActorFactory.h

index d52ead3f58e1a06a13937114648eb108a34d11bb..90c4e50cf383859f0bae32954cfc3f379fa1d2a5 100644 (file)
@@ -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:
index 75cfea0f19a6407a349ed6572ca5d9ba826e6d36..8a6c5de09d7987afc05b5e1c78aaad9a96ecf4c8 100644 (file)
@@ -242,6 +242,7 @@ class VTKOCC_EXPORT VISU_Actor :
   vtkSmartPointer<vtkDataSetMapper> myMapper;
 
   VISU::TActorFactory* myActorFactory;
+  boost::signal1<void,VISU_Actor*> myDestroySignal;
 
   vtkSmartPointer<VTKViewer_ShrinkFilter> myShrinkFilter;
   bool myIsShrinkable;
index 2cda66685c7d1ce9a106cbe19bbe464c0b9c3f5b..d594f5b8f91371a1636c8845995db7e239e55161 100644 (file)
 #ifndef VISU_ACTOR_FACTORY_H
 #define VISU_ACTOR_FACTORY_H
 
+#include <boost/signals/trackable.hpp>
+
 class VISU_Actor;
 
 //----------------------------------------------------------------------------
 namespace VISU 
 { 
-  struct TActorFactory
+  struct TActorFactory: public virtual boost::bsignals::trackable
   {
+    virtual 
+    ~TActorFactory()
+    {}
+
     virtual 
     void
     UpdateActor(VISU_Actor* theActor) = 0;