From fa820ffdb5f2088a4566d25a336a72d67a309335 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@orfeo-toolbox.org> Date: Mon, 5 Oct 2009 15:15:31 +0200 Subject: [PATCH] BUG: Forcing ImageIO to NULL after writing in order to ensure a proper delete of the ImageIO (and a proper final GDALClose()) --- Code/IO/otbGDALImageIO.cxx | 6 +----- Code/IO/otbImageFileWriter.txx | 4 +++- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Code/IO/otbGDALImageIO.cxx b/Code/IO/otbGDALImageIO.cxx index ac0aef1919..b2e25335e7 100644 --- a/Code/IO/otbGDALImageIO.cxx +++ b/Code/IO/otbGDALImageIO.cxx @@ -772,17 +772,13 @@ void GDALImageIO::Write(const void* buffer) { itkExceptionMacro(<< "Error while writing image (GDAL format) " << m_FileName.c_str()<<"."); } + m_poBands[nbComponents]->FlushCache(); } delete [] value; value = NULL; m_poDataset->FlushCache(); - if(m_poDataset != NULL) - { - GDALClose(m_poDataset); - m_poDataset = NULL; - } } /** TODO : Methode WriteImageInformation non implementee */ diff --git a/Code/IO/otbImageFileWriter.txx b/Code/IO/otbImageFileWriter.txx index 267287be33..ea5f2ac0da 100644 --- a/Code/IO/otbImageFileWriter.txx +++ b/Code/IO/otbImageFileWriter.txx @@ -73,7 +73,9 @@ ImageFileWriter<TInputImage> itk::ImageIOFactory::WriteMode ) ); this->SetNumberOfStreamDivisions( static_cast<unsigned int>( CalculateNumberOfStreamDivisions() ) ); this->Superclass::Write(); - + //TODO: Force ImageIO desctructor. Should be fixed once GDALImageIO + //will be refactored. + this->SetImageIO(NULL); } /** -- GitLab