Bug report #20097

iface.addvectorlayer doesn't work in processing script

Added by Vincent Dionne over 5 years ago. Updated over 5 years ago.

Affected QGIS version:3.2.2 Regression?:Yes
Operating System:Windows 7 Easy fix?:No
Pull Request or Patch supplied:No Resolution:wontfix
Crashes QGIS or corrupts data:No Copied to github as #:27919



if you try to load a layer within a processing script using : layer = iface.addVectorLayer("path2asimpleshapefile.shp","test", "ogr").

The layer will not be added on the canvas. But the layer object will be OK.

NB: I noticed that it is working if you remove all parameter from the script But it will not work if you add any parameter ( QgsProcessingParameterVectorLayer for example)

It was working fine in 2.18.

thank you,


#1 Updated by Nyall Dawson over 5 years ago

  • Resolution set to wontfix
  • Status changed from Open to Rejected

This isnt thread safe, so not possible in 3.x. use context.addLayerToLoadOnCompletion instead

Also available in: Atom PDF