On Fri, 19 Apr 2019 at 23:24, David Marteau <dmart...@3liz.com> wrote:
>
> Hi devs,
>
> I have  a strange behavior with QgsPathResolver that prevent layer to be 
> loaded if a QgsProject read config file from relative path:
>
> The problem has been reduced to the following behavior (pyQgis):
>
> ```
> # Init a QgsPathResolver as with a relative path
> pr = QgsPathResolver('./geography/data/france_parts.qgs')

Isn't this an odd/dangerous/fragile situation to begin with? I'd be in
favour of requiring QgsPathResolver to accept only absolute paths in
the constructor.

Nyall


>
> pr.readPath('./france_parts/france_parts.shp')
> # Output -> '/geography/data/france_parts/france_parts.shp'
> # Note the leading '/'
> ```
>
> Worst:
> ```
> pr = QgsPathResolver('../geography/data/france_parts.qgs')
>
> pr.readPath('./france_parts/france_parts.shp')
> # Output -> '/../geography/data/france_parts/france_parts.shp'
> # which is a meaningless path
> ```
>
> The side effect is that if you do:
> ```
> prj = QgsProject()
> prj.read("./geography/data/france_parts.qgs")
> ```
> then you get the error:
> ```
>
> Qgis OGR: Cannot open /geography/data/france_parts/france_parts.shp.()
> Qgis : 1 unavailable layers found:
> Qgis :  * ./france_parts/france_parts.shp
>
> ```
>
> This is with Qgis 3.6.1
>
> Can anybody confirm that this behavior is a bug ? I will submit a PR  if this 
> is the case.
> Thanks,
>
> Cheers
> David
>
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer@lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
_______________________________________________
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to