]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To fix a regressions with crash on destroying Gauss Points presentation
authorapo <apo@opencascade.com>
Fri, 1 Dec 2006 08:52:43 +0000 (08:52 +0000)
committerapo <apo@opencascade.com>
Fri, 1 Dec 2006 08:52:43 +0000 (08:52 +0000)
src/OBJECT/VISU_VectorsAct.cxx
src/OBJECT/VISU_VectorsAct.h
src/VISU_I/VISU_GaussPoints_i.cc
src/VISU_I/VISU_GaussPoints_i.hh
src/VISU_I/VISU_Prs3d_i.cc
src/VISU_I/VISU_Prs3d_i.hh
src/VISU_I/VISU_Vectors_i.cc
src/VISU_I/VISU_Vectors_i.hh

index 9666b5689ffd82bcb0d9e5977e5e953c77c09c42..ce2f67c3359e66be15e0c6de26ee465a551d9aaa 100644 (file)
@@ -60,8 +60,7 @@ VISU_VectorsAct
 ::SetPipeLine(VISU_PipeLine* thePipeLine) 
 {
   myVectorsPL = dynamic_cast<VISU_VectorsPL*>(thePipeLine);
-  VISU_Actor::SetPipeLine(myVectorsPL);
-  myVectorsPL->Delete();
+  VISU_Actor::SetPipeLine(myVectorsPL.GetPointer());
 }
 
 
index 06436cc4f5525409b1576f895de0fe039928abf8..cc76ce4867ac088aca2d862266239c82b518f31d 100644 (file)
@@ -31,6 +31,8 @@
 
 #include "VISU_ScalarMapAct.h"
 
+#include <vtkSmartPointer.h>
+
 class VTKViewer_Transform;
 class VISU_VectorsPL;
 
@@ -68,7 +70,7 @@ class VTKOCC_EXPORT VISU_VectorsAct : public VISU_ScalarMapAct
   VISU_VectorsAct();
   ~VISU_VectorsAct();
 
-  VISU_VectorsPL* myVectorsPL;
+  vtkSmartPointer<VISU_VectorsPL> myVectorsPL;
 };
 
 #endif
index 876baac4e0caa8176cb9f338c585c670e4875d5b..43edd863d2383ff9d4db2ff39fdd836e9c18f9fd 100644 (file)
@@ -571,7 +571,7 @@ VISU::GaussPoints_i
 //----------------------------------------------------------------------------
 VISU_PipeLine* 
 VISU::GaussPoints_i
-::GetPL()
+::GetActorPipeLine()
 {
   // We create a new PipeLine instance in order to provide
   //   different representations for different actors (basic and segmented)
@@ -590,7 +590,6 @@ VISU::GaussPoints_i
 {
   try{
     TSuperClass::CreateActor(theActor);
-    theActor->GetPipeLine()->Delete();
     UpdateActor(theActor);
     return true;
   }catch(...){
index 51d4abcf4aeaa4fbb7a2c8a18b28411cbebf9079..cb28b472a89dbbee2ce63e0b0e80791929253a80 100644 (file)
@@ -277,7 +277,7 @@ namespace VISU
 
     virtual 
     VISU_PipeLine* 
-    GetPL();
+    GetActorPipeLine();
     
     bool
     OnCreateActor(VISU_GaussPtsAct* theActor);
index 651f2d8e7f03356b8cc68a367cd20a09fe4c0405..795c4e26c63426f19f5361a0a5cc0ab247c111ec 100644 (file)
@@ -53,7 +53,6 @@ VISU::Prs3d_i
   myActorCollection(vtkActorCollection::New()),
   mySObject(SALOMEDS::SObject::_nil()),
   myIsActiveSatate(true),
-  myPipeLine(NULL),
   myResult(NULL)
 {
   if(MYDEBUG) MESSAGE("Prs3d_i::Prs3d_i - this = "<<this);
@@ -70,8 +69,7 @@ VISU::Prs3d_i
   mySObject(theSObject),
   myActorCollection(vtkActorCollection::New()),
   myIsActiveSatate(true),
-  myResult(theResult),
-  myPipeLine(NULL)
+  myResult(theResult)
 {
   if(MYDEBUG) MESSAGE("Prs3d_i::Prs3d_i - this = "<<this);
   myOffset[0] = myOffset[1] = myOffset[2] = 0;
@@ -383,10 +381,10 @@ VISU_PipeLine*
 VISU::Prs3d_i
 ::GetPipeLine() const
 {
-  if(!myPipeLine)
+  if(!myPipeLine.GetPointer())
     throw std::runtime_error("VISU::Prs3d_i::myPipeLine == NULL !!!");
 
-  return myPipeLine;
+  return myPipeLine.GetPointer();
 }
 
 //----------------------------------------------------------------------------
@@ -395,6 +393,8 @@ VISU::Prs3d_i
 ::SetPipeLine(VISU_PipeLine* thePipeLine)
 {
   myPipeLine = thePipeLine;
+  if(thePipeLine)
+    thePipeLine->Delete();
 }
 
 //----------------------------------------------------------------------------
@@ -402,13 +402,13 @@ bool
 VISU::Prs3d_i
 ::IsPipeLineExists()
 {
-  return myPipeLine != NULL;
+  return myPipeLine.GetPointer() != NULL;
 }
 
 //----------------------------------------------------------------------------
 VISU_PipeLine* 
 VISU::Prs3d_i
-::GetPL()
+::GetActorPipeLine()
 {
   return GetPipeLine();
 }
@@ -457,7 +457,11 @@ VISU::Prs3d_i
     theActor->SetPrs3d(this);
     theActor->SetShrinkFactor();
     theActor->SetPosition(myOffset[0],myOffset[1],myOffset[2]);
-    theActor->SetPipeLine(GetPipeLine());
+    theActor->SetPipeLine(GetActorPipeLine());
+    if(theActor->GetPipeLine() != GetPipeLine()){
+       // To decrease actor'ss pipeline reference counter
+      theActor->GetPipeLine()->Delete();
+    }
 
     theActor->SetFactory(this);
     myUpdateActorsSignal.connect(boost::bind(&VISU_Actor::UpdateFromFactory,theActor));
@@ -480,7 +484,7 @@ void
 VISU::Prs3d_i
 ::RemoveActor(VISU_Actor* theActor) 
 {
-  if(MYDEBUG) MESSAGE("Prs3d_i::RemoveActor - this = "<<this<<"; theActor = "<<theActor);
+  if(MYDEBUG) MESSAGE("Prs3d_i::RemoveActor - this = "<<this<<"; theActor = "<<theActor<<"; "<<theActor->GetReferenceCount());
   myActorCollection->RemoveItem(theActor);
 }
 
index 9c3571948706532b32426a23fade17aeee5b00d5..b52c09ecbe019153e11e7ea491f5aca7d5d871ce 100644 (file)
@@ -296,7 +296,7 @@ namespace VISU
     //! Gets or creates VISU_PipeLine instance for actor initilization
     virtual 
     VISU_PipeLine* 
-    GetPL();
+    GetActorPipeLine();
 
     //! To check dataset validity, throws std::exception if not valid
     virtual
@@ -330,7 +330,7 @@ namespace VISU
     boost::signal0<void> myRemoveActorsFromRendererSignal;
     vtkSmartPointer<vtkActorCollection> myActorCollection;
 
-    VISU_PipeLine *myPipeLine;
+    vtkSmartPointer<VISU_PipeLine> myPipeLine;
 
     Handle(SALOME_InteractiveObject) myIO;
 
index 114376995a5b67f547025a760cb82f783fb6e42a..fb73be755a1507d43fcfb8a239482c72498c1eeb 100644 (file)
@@ -261,7 +261,7 @@ VISU::Vectors_i
 //---------------------------------------------------------------
 VISU_PipeLine* 
 VISU::Vectors_i
-::GetPL()
+::GetActorPipeLine()
 {
   VISU_PipeLine* aPipeLine = VISU_VectorsPL::New();
   aPipeLine->SetIDMapper(GetPipeLine()->GetIDMapper());
index 80bdc0515a4948fbf2de363269b06bdc1b17663b..c84c2837ed30213b5b00182cf10ce1637c988fea 100644 (file)
@@ -108,7 +108,7 @@ namespace VISU
 
     virtual
     VISU_PipeLine* 
-    GetPL();
+    GetActorPipeLine();
 
     VISU_VectorsPL *myVectorsPL;
     float myLineWidth;