Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[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.
  • Loading branch information
nyalldawson committed Feb 6, 2019
1 parent d61694c commit 2c64cec
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 27 deletions.
8 changes: 0 additions & 8 deletions src/providers/gdal/qgsgdaldataitems.cpp
Expand Up @@ -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;
}
}


Expand Down
19 changes: 0 additions & 19 deletions src/providers/ogr/qgsogrdataitems.cpp
Expand Up @@ -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();

Expand Down

0 comments on commit 2c64cec

Please sign in to comment.