Bug report #17155

Crash when creating XYZ layer from python

Added by Hugo Mercier over 6 years ago. Updated over 6 years ago.

Assignee:Alessandro Pasotti
Category:Data Provider
Affected QGIS version:master Regression?:No
Operating System:Linux Ubuntu Easy fix?:No
Pull Request or Patch supplied:Yes Resolution:
Crashes QGIS or corrupts data:Yes Copied to github as #:25054


Try something like

l = QgsVectorLayer("crs=EPSG:3857&format&type=xyz&url=http://b.tile.openstreetmap.org/{z}/{x}/{y}.png&zmax=18&zmin=0", "wms", "wms")

It kabooms in QgsVectorLayer::setDataProvider, when calling updateFields()

Observed with qgis 2.18 and 2.99

Adding this XYZ layer works fine with the browser

Associated revisions

Revision 2523d735
Added by Alessandro Pasotti over 6 years ago

[bugfix] Prevent a bad crash when provider is wrong

Fixes #17155


#1 Updated by Nyall Dawson over 6 years ago

  • Status changed from Open to Feedback

Shouldn't that be QgsRasterLayer?

#2 Updated by Hugo Mercier over 6 years ago

  • Resolution set to invalid

Of course it is ... !

Works correctly with a QgsRasterLayer, thanks. I did not get enough coffee this morning apparently ... :/

What is a bit confusing is that it does not immediately return and says the provider is unknown. I guess this is because "wms" is also a raster provider.

#3 Updated by Alessandro Pasotti over 6 years ago

  • Assignee set to Alessandro Pasotti

#4 Updated by Alessandro Pasotti over 6 years ago

  • Pull Request or Patch supplied changed from No to Yes
  • Resolution deleted (invalid)

Not fixable due to this cast: https://github.com/qgis/QGIS/blob/master/src/core/qgsvectorlayer.cpp#L1538
I don't know the reason why the dynamic cast was removed, but maybe time to re-introduce it
See: https://github.com/qgis/QGIS/pull/5552

#5 Updated by Anonymous over 6 years ago

  • % Done changed from 0 to 100
  • Status changed from Feedback to Closed

Also available in: Atom PDF