Bug report #21676

QgsProcessingAlgorithm / add Layer to project

Added by Valérian LEBERT about 5 years ago. Updated about 5 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Processing/Core
Affected QGIS version:3.4.5 Regression?:No
Operating System:Windows 10 64bit Easy fix?:No
Pull Request or Patch supplied:No Resolution:no timely feedback
Crashes QGIS or corrupts data:No Copied to github as #:29492

Description

Hi,

I am trying to add a layer to project in a QgsProcessingAlgorithm.

I tried the folowing code :

vlayer1 = QgsVectorLayer('Point?crs=epsg:4326&field=id:integer&field=name:string(20)&index=yes', 'vlayer1', "memory")
vlayer2 = QgsVectorLayer('Point?crs=epsg:4326&field=id:integer&field=name:string(20)&index=yes', 'vlayer2', "memory")
vlayer3 = QgsVectorLayer('Point?crs=epsg:4326&field=id:integer&field=name:string(20)&index=yes', 'vlayer3', "memory")
vlayer4 = QgsVectorLayer('Point?crs=epsg:4326&field=id:integer&field=name:string(20)&index=yes', 'vlayer4', "memory")

context.addLayerToLoadOnCompletion(vlayer1.id(),context.LayerDetails('toto', QgsProject.instance(), self.OUTPUT))
context.addLayerToLoadOnCompletion(vlayer2.id(),context.LayerDetails('toto', context.project(), self.OUTPUT))
QgsProject.instance().addMapLayer(vlayer3, True)
context.project().addMapLayer(vlayer4, True)

None of the layer is loaded.
OUTPUT variable is a string :
OUTPUT = 'OUTPUT'

I get a warning on processing feedback with no details in message log :

Chargement des couches de résultat
Les couches suivantes n'ont pas été générées correctement.<ul><li>vlayer1_98306459_f1bc_4285_b8dc_660502e5cb47</li><li>vlayer2_040a7ea0_7a5f_4e02_bfd1_4ce311c60219</li></ul>Vous pouvez vérifier le Panel de messages du journal dans la fenêtre principale de QGIS pour trouver plus d'informations à propos de l'exécution de l'algorithme.

Am i doing wrong or is there something broken in procesing API?

Thanks
Valérian

History

#1 Updated by Giovanni Manghi about 5 years ago

  • Status changed from Open to Feedback

If this is not an issue report but rather a question this should be posted in the proper channels, the users/devolpers mailing lists, etc.

#2 Updated by Alexander Bruy about 5 years ago

  • Resolution set to no timely feedback
  • Status changed from Feedback to Closed

Also available in: Atom PDF