[QGIS-Developer] Processing Script addLayerToLoadOnCompletion

Luigi Pirelli luipir at gmail.com
Tue Sep 4 01:38:00 PDT 2018


are you reloading processing plugin? the temporary path of processing are
statically set once (c++ static var in QgsProcessingUtils) for qgis session
=> if you reload the processing plugin without exitig processing (e.g. to
update the list of scripts), the oldtemp folder is no more available but
still referenced => generating strange errors at the end of any process.
Just rerun qgis to check if this is the problem.

There is no easy fix other that avoid static variable end method (e.g.
refactoring) of QgsProcessignUtils, bts is not a common use case errors,
but only happens to script developers => no fix is necessary.

Luigi Pirelli

**************************************************************************************************
* LinkedIn: https://www.linkedin.com/in/luigipirelli
* Stackexchange: http://gis.stackexchange.com/users/19667/luigi-pirelli
* GitHub: https://github.com/luipir
* Mastering QGIS 2nd Edition:
*
https://www.packtpub.com/big-data-and-business-intelligence/mastering-qgis-second-edition
* Hire me: http://goo.gl/BYRQKg
**************************************************************************************************


On Mon, 3 Sep 2018 at 16:52, matteo <matteo.ghetta at gmail.com> wrote:

> Hi all,
>
> I was thinking to add a small example of addLayerToLoadOnCompletion
> function to the ScriptTemplate of Processing. The code is the following:
>
>     buffered_layer = processing.run("native:buffer", parameters={
>         'INPUT': dest_id,
>         'DISTANCE': 10000,
>         'SEGMENTS': 5,
>         'END_CAP_STYLE': 0,
>         'JOIN_STYLE': 0,
>         'MITER_LIMIT': 2,
>         'DISSOLVE': False,
>         'OUTPUT': 'memory:'
>     }, context=context, feedback=feedback)['OUTPUT']
>
>     feedback.pushDebugInfo(str(dest_id))
>
>     context.addLayerToLoadOnCompletion(buffered_layer.source(),
> context.LayerDetails(
>         name='new_layer',
>         project=context.project()
>     ))
>
> but Processing always throws this error:
>
> The following layers were not correctly
>
> generated.<ul><li>Polygon?crs=EPSG:3003&field=ID:long(10)&field=fk:string(254)&field=ROTAZ:long(10)&field=DIMENS:long(10)&field=ETICHETTA:string(254)&field=VALORE:long(10)&field=T_MIN:double(20,5)&field=T_MAX:double(20,5)&field=PIOGGIA:double(20,5)&field=LARGH:double(20,5)&field=LUNG:double(20,5)&field=assex:string(254)&field=assey:string(254)&field=colore:string(38)&field=xlab:double(10,2)&field=ylab:double(10,2)&field=raster:double(23,15)&field=raster_1:double(23,15)&field=raster_2:double(23,15)&uid={685540af-711d-462b-a9d0-9b00af4c2f6a}</li></ul>You
> can check the 'Log Messages Panel' in QGIS main window to find more
> information about the execution of the algorithm.
>
>
> Am I missing something?
>
> Thanks for any suggestion
>
> Matteo
>
>
>
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20180904/6790de57/attachment.html>


More information about the QGIS-Developer mailing list