1

I have a WFS layer, served by Geoserver, loaded in QGIS using the standard 'Add WFS layer' dialog. When I try to remove it using:

QgsMapLayerRegistry().instance().removeMapLayer(wfs_layer.id())

I get a full application crash, with no Python errors. This also happens when I use wfs_layer.reload() and wfs_layer.dataProvider().reloadData(). These methods previously worked on the same WFS layer. The service and content of the layer has not changed. The methods work when manipulating a (PostgreSQL) database layer.

I have made no changes to the code that I can see would affect the ability to reload data.

Any ideas or experiences?

  • 1
    I logged a bug here: hub.qgis.org/issues/11062, it seems to be an issue with manipulating a cached WFS layer (i.e. a WFS layer without a 'bbox' parameter in the url) – James N Aug 15 '14 at 11:06
  • Seems to be now fixed. :) – cag Mar 3 '15 at 15:29
1

Have you tried to use

QgsMapLayerRegistry().instance().removeMapLayers(wfs_layer.id())

or

QgsMapLayerRegistry().instance().removeMapLayers([wfs_layer.id()])

instead? (Note the plural "s" at removeMapLayers)
This worked for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.