mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-01 00:46:20 -05:00
[Browser] Fix invalid detection of OGR VRT by GDAL provider, and fix broken detection of OGR VRT (fixes #16806)
This commit is contained in:
parent
cc96f51e62
commit
49071808ac
@ -273,13 +273,13 @@ QGISEXTERN QgsDataItem *dataItem( QString path, QgsDataItem *parentItem )
|
||||
// do not print errors, but write to debug
|
||||
CPLPushErrorHandler( CPLQuietErrorHandler );
|
||||
CPLErrorReset();
|
||||
if ( ! GDALIdentifyDriver( path.toUtf8().constData(), nullptr ) )
|
||||
GDALDriverH hDriver = GDALIdentifyDriver( path.toUtf8().constData(), nullptr );
|
||||
CPLPopErrorHandler();
|
||||
if ( !hDriver || GDALGetDriverShortName( hDriver ) == QLatin1String( "OGR_VRT" ) )
|
||||
{
|
||||
QgsDebugMsgLevel( "Skipping VRT file because root is not a GDAL VRT", 2 );
|
||||
CPLPopErrorHandler();
|
||||
return nullptr;
|
||||
}
|
||||
CPLPopErrorHandler();
|
||||
}
|
||||
// add the item
|
||||
QStringList sublayers;
|
||||
|
@ -592,21 +592,14 @@ QGISEXTERN QgsDataItem *dataItem( QString path, QgsDataItem *parentItem )
|
||||
// if this is a VRT file make sure it is vector VRT to avoid duplicates
|
||||
if ( suffix == QLatin1String( "vrt" ) )
|
||||
{
|
||||
GDALDriverH hDriver = GDALGetDriverByName( "OGR_VRT" );
|
||||
if ( hDriver )
|
||||
CPLPushErrorHandler( CPLQuietErrorHandler );
|
||||
CPLErrorReset();
|
||||
GDALDriverH hDriver = GDALIdentifyDriver( path.toUtf8().constData(), nullptr );
|
||||
CPLPopErrorHandler();
|
||||
if ( !hDriver || GDALGetDriverShortName( hDriver ) == QLatin1String( "VRT" ) )
|
||||
{
|
||||
// do not print errors, but write to debug
|
||||
CPLPushErrorHandler( CPLQuietErrorHandler );
|
||||
CPLErrorReset();
|
||||
GDALDatasetH hDataSource = GDALOpenEx(
|
||||
path.toLocal8Bit().constData(), GDAL_OF_VECTOR, nullptr, nullptr, nullptr );
|
||||
CPLPopErrorHandler();
|
||||
if ( ! hDataSource )
|
||||
{
|
||||
QgsDebugMsgLevel( "Skipping VRT file because root is not a OGR VRT", 2 );
|
||||
return nullptr;
|
||||
}
|
||||
GDALClose( hDataSource );
|
||||
QgsDebugMsgLevel( "Skipping VRT file because root is not a OGR VRT", 2 );
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
// Handle collections
|
||||
|
@ -2403,7 +2403,7 @@ QString createFilters( const QString &type )
|
||||
{
|
||||
sDirectoryDrivers += QObject::tr( "U.S. Census TIGER/Line" ) + ",TIGER;";
|
||||
}
|
||||
else if ( driverName.startsWith( QLatin1String( "VRT" ) ) )
|
||||
else if ( driverName.startsWith( QLatin1String( "OGR_VRT" ) ) )
|
||||
{
|
||||
sFileFilters += createFileFilter_( QObject::tr( "VRT - Virtual Datasource" ),
|
||||
QStringLiteral( "*.vrt *.ovf" ) );
|
||||
|
Loading…
x
Reference in New Issue
Block a user