Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
qgsogrsourceselect.cpp: make it identify vector drivers only (fixes #…
  • Loading branch information
rouault committed Jul 13, 2021
1 parent db74bf5 commit cec5a39
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/core/providers/gdal/qgsgdaldataitems.cpp
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/core/providers/ogr/qgsogrdataitems.cpp
Expand Up @@ -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" );
}
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgis.cpp
Expand Up @@ -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/" );
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/providers/gdal/qgsgdalsourceselect.cpp
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/gui/providers/ogr/qgsogrsourceselect.cpp
Expand Up @@ -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;

Expand Down

0 comments on commit cec5a39

Please sign in to comment.