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: [email protected]

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

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

_______________________________________________
QGIS-Developer mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to