Skip to content
Permalink
Browse files
Merge pull request #44146 from rouault/fix_44108
qgsogrsourceselect.cpp: make it identify vector drivers only (fixes #44108)
  • Loading branch information
rouault committed Jul 13, 2021
2 parents 1dfe718 + cec5a39 commit 6db6de3fe795ae3efd8c3c0e0e6c0b9fdfc00173
@@ -314,9 +314,9 @@ QgsDataItem *QgsGdalDataItemProvider::createDataItem( const QString &pathIn, Qgs
// do not print errors, but write to debug
CPLPushErrorHandler( CPLQuietErrorHandler );
CPLErrorReset();
GDALDriverH hDriver = GDALIdentifyDriver( path.toUtf8().constData(), nullptr );
GDALDriverH hDriver = GDALIdentifyDriverEx( path.toUtf8().constData(), GDAL_OF_RASTER, nullptr, nullptr );
CPLPopErrorHandler();
if ( !hDriver || GDALGetDriverShortName( hDriver ) == QLatin1String( "OGR_VRT" ) )
if ( !hDriver )
{
QgsDebugMsgLevel( QStringLiteral( "Skipping VRT file because root is not a GDAL VRT" ), 2 );
return nullptr;
@@ -589,7 +589,7 @@ QgsDataItem *QgsOgrDataItemProvider::createDataItem( const QString &pathIn, QgsD

// GDAL 3.1 Shapefile driver directly handles .shp.zip files
if ( path.endsWith( QLatin1String( ".shp.zip" ), Qt::CaseInsensitive ) &&
GDALIdentifyDriver( path.toUtf8().constData(), nullptr ) )
GDALIdentifyDriverEx( path.toUtf8().constData(), GDAL_OF_VECTOR, nullptr, nullptr ) )
{
suffix = QStringLiteral( "shp.zip" );
}
@@ -715,9 +715,9 @@ QgsDataItem *QgsOgrDataItemProvider::createDataItem( const QString &pathIn, QgsD
{
CPLPushErrorHandler( CPLQuietErrorHandler );
CPLErrorReset();
GDALDriverH hDriver = GDALIdentifyDriver( path.toUtf8().constData(), nullptr );
GDALDriverH hDriver = GDALIdentifyDriverEx( path.toUtf8().constData(), GDAL_OF_VECTOR, nullptr, nullptr );
CPLPopErrorHandler();
if ( !hDriver || GDALGetDriverShortName( hDriver ) == QLatin1String( "VRT" ) )
if ( !hDriver )
{
QgsDebugMsgLevel( QStringLiteral( "Skipping VRT file because root is not a OGR VRT" ), 2 );
return nullptr;
@@ -204,7 +204,7 @@ QString qgsVsiPrefix( const QString &path )
else if ( path.endsWith( QLatin1String( ".shp.zip" ), Qt::CaseInsensitive ) )
{
// GDAL 3.1 Shapefile driver directly handles .shp.zip files
if ( GDALIdentifyDriver( path.toUtf8().constData(), nullptr ) )
if ( GDALIdentifyDriverEx( path.toUtf8().constData(), GDAL_OF_VECTOR, nullptr, nullptr ) )
return QString();
return QStringLiteral( "/vsizip/" );
}
@@ -260,7 +260,7 @@ void QgsGdalSourceSelect::fillOpenOptions()
return;

GDALDriverH hDriver;
hDriver = GDALIdentifyDriver( mDataSources[0].toUtf8().toStdString().c_str(), nullptr );
hDriver = GDALIdentifyDriverEx( mDataSources[0].toUtf8().toStdString().c_str(), GDAL_OF_RASTER, nullptr, nullptr );
if ( hDriver == nullptr )
return;

@@ -651,7 +651,7 @@ void QgsOgrSourceSelect::fillOpenOptions()
if ( STARTS_WITH_CI( mDataSources[0].toUtf8().toStdString().c_str(), "PG:" ) )
hDriver = GDALGetDriverByName( "PostgreSQL" ); // otherwise the PostgisRaster driver gets identified
else
hDriver = GDALIdentifyDriver( mDataSources[0].toUtf8().toStdString().c_str(), nullptr );
hDriver = GDALIdentifyDriverEx( mDataSources[0].toUtf8().toStdString().c_str(), GDAL_OF_VECTOR, nullptr, nullptr );
if ( hDriver == nullptr )
return;

0 comments on commit 6db6de3

Please sign in to comment.