[raster] Remove preexisting pyramid files when over-writing a raster (#7677)

(failing to do so can lead to new raster relying on old pyramid
files, corrupting the rendering)
This commit is contained in:
Mathieu Pellerin 2018-08-24 15:39:16 +07:00 committed by GitHub
parent 04cdc9bf30
commit bf0962fa9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -130,6 +130,14 @@ QgsRasterFileWriter::WriterError QgsRasterFileWriter::writeRaster( const QgsRast
}
}
// Remove pre-existing overview files to avoid using those with new raster
QFile pyramidFile( mOutputUrl + ( mTiledMode ? ".vrt.ovr" : ".ovr" ) );
if ( pyramidFile.exists() )
pyramidFile.remove();
pyramidFile.setFileName( mOutputUrl + ( mTiledMode ? ".vrt.rrd" : ".rrd" ) );
if ( pyramidFile.exists() )
pyramidFile.remove();
if ( mMode == Image )
{
WriterError e = writeImageRaster( &iter, nCols, nRows, outputExtent, crs, feedback );