Skip to content

Commit

Permalink
Fix crash when zooming in PostGIS raster layers (ticket 20747)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Jan 18, 2019
1 parent d3c04c2 commit 0072dbb
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/providers/gdal/qgsgdalprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand Down

0 comments on commit 0072dbb

Please sign in to comment.