Skip to content
Permalink
Browse files

Fix crash when zooming in PostGIS raster layers (ticket 20747)

  • Loading branch information
mhugent authored and nyalldawson committed Jan 21, 2019
1 parent 195d98f commit 9da842d48881fe54af734f033be91c2772fe1177
Showing with 12 additions and 4 deletions.
  1. +12 −4 src/providers/gdal/qgsgdalprovider.cpp
@@ -200,12 +200,20 @@ QgsGdalProvider::QgsGdalProvider( const QgsGdalProvider &other )
: QgsRasterDataProvider( other.dataSourceUri(), QgsDataProvider::ProviderOptions() )
, mUpdate( false )
{
QString driverShortName;
if ( other.mGdalBaseDataset )
{
driverShortName = GDALGetDriverShortName( GDALGetDatasetDriver( other.mGdalBaseDataset ) );
}


// The JP2OPENJPEG driver might consume too much memory on large datasets
// so make sure to really use a single one.
bool forceUseSameDataset =
( other.mGdalBaseDataset &&
GDALGetDatasetDriver( other.mGdalBaseDataset ) == GDALGetDriverByName( "JP2OPENJPEG" ) ) ||
CSLTestBoolean( CPLGetConfigOption( "QGIS_GDAL_FORCE_USE_SAME_DATASET", "FALSE" ) );
// The PostGISRaster driver internally uses a per-thread connection cache.
// This can lead to crashes if two datasets created by the same thread are used at the same time.
bool forceUseSameDataset = ( driverShortName.toUpper() == QStringLiteral( "JP2OPENJPEG" ) ||
driverShortName == QStringLiteral( "PostGISRaster" ) ||
CSLTestBoolean( CPLGetConfigOption( "QGIS_GDAL_FORCE_USE_SAME_DATASET", "FALSE" ) ) );

if ( forceUseSameDataset )
{

0 comments on commit 9da842d

Please sign in to comment.
You can’t perform that action at this time.