From: srit <srit>
Date: Mon, 28 Mar 2011 13:51:00 +0000 (+0000)
Subject: Use smart pointers for vvSlicers
X-Git-Tag: v1.2.0~96
X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=9c1c3b2a6def6a7ee512919c105ceea8939e7f66;p=clitk.git

Use smart pointers for vvSlicers
---

diff --git a/vv/vvSlicerManager.cxx b/vv/vvSlicerManager.cxx
index 8a68f28..1daee2c 100644
--- a/vv/vvSlicerManager.cxx
+++ b/vv/vvSlicerManager.cxx
@@ -60,19 +60,12 @@ vvSlicerManager::vvSlicerManager(int numberOfSlicers)
   mFusionWindow = 1000;
   mFusionLevel = 1000;
 
-  mReader = NULL;
-  mImage = NULL;
-  mVF=NULL;
-  mVectorReader = NULL;
-  mOverlayReader = NULL;
-  mFusionReader = NULL;
   mLandmarks = NULL;
   mLinkedId.resize(0);
 
-  for ( int i = 0; i < numberOfSlicers; i++) {
-    vvSlicer *slicer = vvSlicer::New();
-    mSlicers.push_back(slicer);
-  }
+  for ( int i = 0; i < numberOfSlicers; i++)
+    mSlicers.push_back(vtkSmartPointer<vvSlicer>::New());
+
   mPreviousSlice.resize(numberOfSlicers);
   mPreviousTSlice.resize(numberOfSlicers);
 }
@@ -82,10 +75,6 @@ vvSlicerManager::vvSlicerManager(int numberOfSlicers)
 //----------------------------------------------------------------------------
 vvSlicerManager::~vvSlicerManager()
 {
-  for ( unsigned int i = 0; i < mSlicers.size(); i++) {
-    if (mSlicers[i] != NULL)
-      mSlicers[i]->Delete();
-  }
   if (mLandmarks)
     delete mLandmarks;
 }
diff --git a/vv/vvSlicerManager.h b/vv/vvSlicerManager.h
index 10e9c9d..ea079c4 100644
--- a/vv/vvSlicerManager.h
+++ b/vv/vvSlicerManager.h
@@ -214,7 +214,7 @@ signals :
   void AVerticalSliderHasChanged(int slicer, int slice);
 
 protected:
-  std::vector<vvSlicer*> mSlicers;
+  std::vector< vtkSmartPointer<vvSlicer> > mSlicers;
   vvImageReader::Pointer mReader;
   vvImageReader::Pointer mOverlayReader;
   vvImageReader::Pointer mFusionReader;