From 2c64cece0d1a51c37d27c1b11e76d76bb62184f3 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Wed, 6 Feb 2019 06:47:20 +1000 Subject: [PATCH] [browser] Avoid always opening every file using gdal to test for update capabilities This is no longer required - it was previously done in order to detect if the item should expose the SetCrs capability, but that's deprecated and unused. Fixes #16807, fixes #20411, and avoids QGIS opening every file encountered in the browser even when the Data Source setting is set to the default (fast) "Check Extension" setting only. --- src/providers/gdal/qgsgdaldataitems.cpp | 8 -------- src/providers/ogr/qgsogrdataitems.cpp | 19 ------------------- 2 files changed, 27 deletions(-) diff --git a/src/providers/gdal/qgsgdaldataitems.cpp b/src/providers/gdal/qgsgdaldataitems.cpp index 0b4fc8910e7f..d786d0fc95dc 100644 --- a/src/providers/gdal/qgsgdaldataitems.cpp +++ b/src/providers/gdal/qgsgdaldataitems.cpp @@ -48,14 +48,6 @@ QgsGdalLayerItem::QgsGdalLayerItem( QgsDataItem *parent, } else setState( Populated ); - - GDALAllRegister(); - gdal::dataset_unique_ptr hDS( GDALOpen( mPath.toUtf8().constData(), GA_Update ) ); - - if ( hDS ) - { - mCapabilities |= SetCrs; - } } diff --git a/src/providers/ogr/qgsogrdataitems.cpp b/src/providers/ogr/qgsogrdataitems.cpp index b572671982f1..8dd943b89e7e 100644 --- a/src/providers/ogr/qgsogrdataitems.cpp +++ b/src/providers/ogr/qgsogrdataitems.cpp @@ -53,30 +53,11 @@ QgsOgrLayerItem::QgsOgrLayerItem( QgsDataItem *parent, mIsSubLayer = isSubLayer; mToolTip = uri; setState( Populated ); // children are not expected - - if ( mPath.endsWith( QLatin1String( ".shp" ), Qt::CaseInsensitive ) ) - { - if ( OGRGetDriverCount() == 0 ) - { - OGRRegisterAll(); - } - gdal::dataset_unique_ptr hDataSource( GDALOpenEx( mPath.toUtf8().constData(), GDAL_OF_VECTOR | GDAL_OF_UPDATE, nullptr, nullptr, nullptr ) ); - if ( hDataSource ) - { - mCapabilities |= SetCrs; - } - - // It it is impossible to assign a crs to an existing layer - // No OGR_L_SetSpatialRef : http://trac.osgeo.org/gdal/ticket/4032 - } } bool QgsOgrLayerItem::setCrs( const QgsCoordinateReferenceSystem &crs ) { - if ( !( mCapabilities & SetCrs ) ) - return false; - QString layerName = mPath.left( mPath.indexOf( QLatin1String( ".shp" ), Qt::CaseInsensitive ) ); QString wkt = crs.toWkt();