[QGIS-Developer] QBrowser, QgsGdalLayerItems, QgsOgrLayerItems and non valid layers

Richard Duivenvoorde rdmailings at duif.net
Fri Jul 7 04:35:49 PDT 2017


On 07-07-17 13:11, Even Rouault wrote:
> So what I suspect here is that your QGIS is setup to only look at
> extensions,
> 
> which is the default setting I think.
> 
> See
> 
> https://github.com/qgis/QGIS/blob/master/src/providers/gdal/qgsgdaldataitems.cpp#L145
> 
> and then
> 
> https://github.com/qgis/QGIS/blob/master/src/providers/gdal/qgsgdaldataitems.cpp#L239
> 
> And so for drivers that have both raster&vector capabilities, a file
> will appear twice. Probably
> 
> this logic should be amended for dual capabiiity drivers like GPKG and
> PDF. Actually L246 shows
> 
> a particular case for VRT. But I think this logic is now invalid since
> GDAL 2.0, since

Hi Even,

Thanks for your prompt answer.

Yep, you are right. The default setting is apparently (to save
resources?) to only look at the extension. If I use 'Check file
contents' in "Options/Data Sources/Data source handling/Scan for valid
items in the browser dock" all is fine.

Should we not make this default then?

And still: debugging this with the 'only look at extension' option you
go through:

https://github.com/qgis/QGIS/blob/master/src/providers/gdal/qgsgdaldataitems.cpp#L43

where hDS then is a NULL... And all those items in the browser then show
'error' in their properties.
So only looking only to the extention, the codes still tries to open
them using gdal/ogr anyway.

Isn't it better then to add a flag that this item is not to be opened?
And probably not to be shown in the tree?

Same with ALL .txt files by the way (both in a zip and as file), they
also appear as 'geodata' in the browser, and will fail upon opening.

So currently I see a couple of special cases for which QGIS should check:

- .img files (which are not gis image files)
- .pdf files
- .gpkg files
- .sqlite files
- .txt files
- .tab files (people tend to save tab-delimited files as .tab files)

Should I create an issue for this?

About the VRT / GDAL 2.0

Should I create an issue for that?

Regards,

Richard


More information about the QGIS-Developer mailing list