[QGIS-Developer] QgsExpressionContextGenerator - QgsExpressionLineEdit Crash

Benjamin Jakimow benjamin.jakimow at geo.hu-berlin.de
Mon Nov 23 06:27:02 PST 2020


Dear QGIS Developer Community,

I like to use a QgsExpressionContextGenerator to create the expression 
context for a QgsExpressionLineEdit.
However, when executed in the QGIS python shell, the following code 
crashes my QGIS after clicking on the Expression builder widget:

from  qgis.core  import  (
     QgsExpressionContextGenerator,QgsExpressionContext,QgsExpressionContextUtils
)

from  qgis.gui  import  QgsExpressionLineEdit

class  Generator(QgsExpressionContextGenerator):

     def  __init__(self,*args,**kwds):
         super(Generator,self).__init__(*args,**kwds)

     def  createExpressionContext(self)->  QgsExpressionContext:
         context  =  QgsExpressionContext([QgsExpressionContextUtils.globalScope()])
         print(f'Generated QgsExpressionContext: {context}',flush=True)
         return  context

gen  =  Generator()
w  =  QgsExpressionLineEdit()
w.setExpression("'click edit button ->'")
w.registerExpressionContextGenerator(gen)
w.show()

# now click on edit button to produce a crash

grafik

Any suggestions how I can fix this?

Thanks, Benjamin




-- 
Benjamin Jakimow, Doctoral Researcher
Earth Observation Lab | Geography Department | Humboldt-Universität zu Berlin

e-mail: benjamin.jakimow at geo.hu-berlin.de

phone:  +49 (0) 30 2093 6846
mobile: +49 (0) 157 5656 8477
fax:    +49 (0) 30 2093 6848
mail:   Unter den Linden 6 | 10099 Berlin | Germany
room: 2'211
web:    https://hu-berlin.de/eo-lab

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20201123/08f687fb/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5422 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20201123/08f687fb/attachment-0001.bin>


More information about the QGIS-Developer mailing list