[QGIS-Developer] QGIS3: Python QgsFeatureRenderer subclass problem

Chris Crook ccrook at linz.govt.nz
Tue Feb 13 19:21:52 PST 2018


Hi Nyalll

That's brilliant - thanka\s for taking such a detailed look at this.  There are indeed several other things I need to fix but at least I an approach sorted now.

Chris
________________________________________
From: Nyall Dawson [nyall.dawson at gmail.com]
Sent: 13 February 2018 18:51
To: Chris Crook
Cc: qgis-developer at lists.osgeo.org
Subject: Re: [QGIS-Developer] QGIS3: Python QgsFeatureRenderer subclass problem

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

________________________________

This message contains information, which may be in confidence and may be subject to legal privilege. If you are not the intended recipient, you must not peruse, use, disseminate, distribute or copy this message. If you have received this message in error, please notify us immediately (Phone 0800 665 463 or info at linz.govt.nz) and destroy the original message. LINZ accepts no responsibility for changes to this email, or for any attachments, after its transmission from LINZ. Thank You.


More information about the QGIS-Developer mailing list