From dd5f76100aae9f0a2dc7163327163ffceb37b07e Mon Sep 17 00:00:00 2001 From: srit Date: Fri, 1 Apr 2011 08:51:47 +0000 Subject: [PATCH] Remove leaks related to vvImageWriter --- vv/vvImageWriter.h | 12 ++++++++---- vv/vvMainWindow.cxx | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/vv/vvImageWriter.h b/vv/vvImageWriter.h index e9a9c38..3effb47 100644 --- a/vv/vvImageWriter.h +++ b/vv/vvImageWriter.h @@ -24,12 +24,12 @@ #include "itkCommand.h" #include "vvImage.h" -class vvImageWriter { +class vvImageWriter : public itk::LightObject { public: - // constructor - vvImageWriter(); - ~vvImageWriter(); + typedef vvImageWriter Self; + typedef itk::SmartPointer Pointer; + itkNewMacro(Self); void SetOutputFileName(std::string filename); void SetObserver(itk::Command::Pointer o) { @@ -56,6 +56,10 @@ public: void Update(int dim, std::string OutputPixelType); protected: + // constructor + vvImageWriter(); + ~vvImageWriter(); + //==================================================================== std::string mOutputFilename; itk::Command::Pointer mObserver; diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index 760fa75..885201b 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -2193,7 +2193,7 @@ void vvMainWindow::SaveAs() std::string action = "Saving"; vvProgressDialog progress("Saving "+fileName.toStdString()); qApp->processEvents(); - vvImageWriter *writer = new vvImageWriter; + vvImageWriter::Pointer writer = vvImageWriter::New(); writer->SetOutputFileName(fileName.toStdString()); writer->SetInput(mSlicerManagers[index]->GetImage()); writer->Update(); -- 2.47.1