Import 2017-06-07 23:51:09: master 327e4b5f

Author Committer Branch Timestamp Parent
msmolens msmolens master 2015-09-25 10:55:04 master 6297a072
Affected Issues 0003717: Memory leak when scene saving fails
Changeset

BUG: Fix memory leaks when saving scene fails

This commit replaces manual memory management with smart pointers to fix memory
leaks in vtkITKImageWriter::Write() when an exception occurs while writing the
image.

Fixes issue 0003717:

To reproduce:
 -> Create folder ~/test
 -> Start Slicer
 -> Download MRHead
 -> File -> Save Scene
 -> Click "Change directory for selected files" and select "~/test"
 -> after selecting the folder and before clicking Save => chmod -w ~/test
 -> Click Save
 -> When you get the "Cannot write data file" error, click Yes to say you want to continue despite the problem
 -> When you get the "Cannot write scene file" error, click Yes to say you ignore these errors and close saving
 -> Close Slicer (click Exit and discard modification)

Then, you get the following leaks:

Class "vtkCellData" has 1 instance still around.
Class "vtkInformationIntegerVectorValue" has 3 instances still around.
Class "vtkInformationVector" has 15 instances still around.
Class "vtkPointData" has 1 instance still around.
Class "vtkImageFlip" has 1 instance still around.
Class "vtkTrivialProducer" has 1 instance still around.
Class "vtkMatrix4x4" has 1 instance still around.
Class "vtkPoints" has 1 instance still around.
Class "vtkInformation" has 21 instances still around.
Class "vtkMultiThreader" has 1 instance still around.
Class "vtkInformationIntegerPointerValue" has 2 instances still around.
Class "vtkIdList" has 1 instance still around.
Class "vtkImageExport" has 1 instance still around.
Class "vtkDoubleArray" has 1 instance still around.
Class "vtkAlgorithmOutput" has 1 instance still around.
Class "vtkImageStencilData" has 1 instance still around.
Class "vtkInformationIntegerValue" has 26 instances still around.
Class "vtkExtentTranslator" has 1 instance still around.
Class "vtkImageData" has 1 instance still around.
Class "vtkInformationStringValue" has 1 instance still around.
Class "vtkInformationExecutivePortVectorValue" has 1 instance still around.
Class "vtkShortArray" has 1 instance still around.
Class "vtkVoxel" has 1 instance still around.
Class "vtkFieldData" has 2 instances still around.
Class "vtkInformationDoubleVectorValue" has 2 instances still around.
Class "vtkStreamingDemandDrivenPipeline" has 3 instances still around.
Class "vtkInformationExecutivePortValue" has 4 instances still around.

From: Max Smolens <max.smolens@kitware.com>

git-svn-id: http://svn.slicer.org/Slicer4/trunk@24578 3bd1e089-480b-0410-8dfb-8563597acbee

mod - Libs/vtkITK/vtkITKImageWriter.cxx Diff File