Re: [QGIS-Developer] QGIS3: Python QgsFeatureRenderer subclass problem
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.daw...@gmail.com] Sent: 13 February 2018 18:51 To: Chris Crook Cc: qgis-developer@lists.osgeo.org Subject: Re: [QGIS-Developer] QGIS3: Python QgsFeatureRenderer subclass problem On 11 February 2018 at 21:07, Chris Crook 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 i...@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. ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [QGIS-Developer] QGIS3: Python QgsFeatureRenderer subclass problem
On 11 February 2018 at 21:07, Chris Crook 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 ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [QGIS-Developer] QGIS3: Python QgsFeatureRenderer subclass problem
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 :-) Chris From: Nyall Dawson [nyall.daw...@gmail.com] Sent: 08 February 2018 10:53 To: Chris Crook Cc: qgis-developer@lists.osgeo.org Subject: Re: [QGIS-Developer] QGIS3: Python QgsFeatureRenderer subclass problem On 8 February 2018 at 05:44, Chris Crook wrote: > I am converting a python plugin the implements a subclass of > QgsFeatureRenderer. At the moment the plugin is dying on the startRender > function with the message (from the base class) > > "ASSERT failure in QgsFeatureRenderer::renderFeature: \"renderFeature called > in a different thread - use a cloned renderer instead\" > > I can't see where I should be creating the cloned renderer for the rendering. > I had a look at the QgsSingleSymbolRenderer C++ code and I can't see > anything there, so I'm wondering if the python implementation in some way > corrupts the multiprocessing implementation. Can anyone offer any suggestions > Interesting - is your code public anywhere? I'll take a look. 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 i...@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. ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [QGIS-Developer] QGIS3: Python QgsFeatureRenderer subclass problem
Continued: Ok, understand a bit more now. Still not sure where the clone should be created but if the same renderer is called from more than one thread, as the first time startRender is called it sets the thread id for the rendererer, and thereafter cannot be called with a different thread id. So issue could either be if startRender does not invoke super.startRender (to set thread id) or if called from two threads. From: QGIS-Developer [qgis-developer-boun...@lists.osgeo.org] on behalf of Chris Crook Sent: 08 February 2018 08:45 To: qgis-developer@lists.osgeo.org Subject: [QGIS-Developer] QGIS3: Python QgsFeatureRenderer subclass problem I am converting a python plugin the implements a subclass of QgsFeatureRenderer. At the moment the plugin is dying on the startRender function with the message (from the base class) "ASSERT failure in QgsFeatureRenderer::renderFeature: \"renderFeature called in a different thread - use a cloned renderer instead\" I can't see where I should be creating the cloned renderer for the rendering. I had a look at the QgsSingleSymbolRenderer C++ code and I can't see anything there, so I'm wondering if the python implementation in some way corrupts the multiprocessing implementation. Can anyone offer any suggestions 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 i...@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. ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [QGIS-Developer] QGIS3: Python QgsFeatureRenderer subclass problem
On 8 February 2018 at 05:44, Chris Crook wrote: > I am converting a python plugin the implements a subclass of > QgsFeatureRenderer. At the moment the plugin is dying on the startRender > function with the message (from the base class) > > "ASSERT failure in QgsFeatureRenderer::renderFeature: \"renderFeature called > in a different thread - use a cloned renderer instead\" > > I can't see where I should be creating the cloned renderer for the rendering. > I had a look at the QgsSingleSymbolRenderer C++ code and I can't see > anything there, so I'm wondering if the python implementation in some way > corrupts the multiprocessing implementation. Can anyone offer any suggestions > Interesting - is your code public anywhere? I'll take a look. Nyall ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer