[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.
This commit is contained in:
Nyall Dawson 2019-02-06 06:47:20 +10:00
parent d61694cb42
commit 2c64cece0d
2 changed files with 0 additions and 27 deletions

View File

@ -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;
}
}

View File

@ -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();