[QGIS-Developer] QGIS3: Python QgsFeatureRenderer subclass problem

Nyall Dawson nyall.dawson at gmail.com
Mon Feb 12 21:51:33 PST 2018


On 11 February 2018 at 21:07, Chris Crook <ccrook at linz.govt.nz> wrote:
> Hi Nyall
>
> The code is on github ..
>
> https://github.com/ccrook/QGIS-VectorFieldRenderer-Plugin/tree/qgis3_wip
>
> I've documented this in issue 8 at:
>
> https://github.com/ccrook/QGIS-VectorFieldRenderer-Plugin/issues/8
>
> Any thoughts would be greatly appreciated :-)

Ok, so the issue is that you're trying to call the base class methods by calling

    QgsFeatureRenderer.startRender(context,fields)

That's not valid syntax. In Python 3 you should use:

    super().startRender(context,fields)

Fixing those calls avoids the assert.

...BUT....

You'll get a lot of crashes, because there's other parts of your
renderer which need upgrading to QGIS 3.0 API. And unfortunately when
a renderer crashes in Python code, it segfaults after dumping the
python error to the console. You'll need to run in a console to see
the Python errors which are thrown and upgrade the corresponding API
calls.

Also - I noticed you access a layer from the project within your
startRender method -- is is very unsafe for a renderer to do, since it
is running in a background thread and should not be accessing layers
at all. Just another thing to try to refactor out as you upgrade your
plugin for 3.0!

Nyall


More information about the QGIS-Developer mailing list