Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: unable to convert a C++ 'QPointer<QgsMapLayer>' instance to a Python object #48090

Closed
2 tasks done
jakimowb opened this issue Apr 5, 2022 · 2 comments
Closed
2 tasks done
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Feedback Waiting on the submitter for answers

Comments

@jakimowb
Copy link
Contributor

jakimowb commented Apr 5, 2022

What is the bug or the crash?

The QgsexpresisonContextUtils allows to add add layer specific variables to a QgsExpressionContext.

However, accessing the "layer" variable in python raises a python error (see code example below):

TypeError: unable to convert a C++ 'QPointer' instance to a Python object

Steps to reproduce the issue

The following python creates a vector layer and wants to asses it from a QgsExpressionContext:

from qgis.core import QgsExpressionContext, QgsVectorLayer, QgsExpressionContextUtils

lyr = QgsVectorLayer('point?crs=epsg:4326&field=id:integer', 'dummy', 'memory')

context = QgsExpressionContext()
context.appendScope(QgsExpressionContextUtils.layerScope(lyr))
lyr2 = context.variable('layer')

Versions

QGIS 3.24 and QGIS 3.25 (master) OSGeo4W & Ubuntu 20.04

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

  • I tried with a new QGIS profile

Additional context

No response

@jakimowb jakimowb added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Apr 5, 2022
@nyalldawson
Copy link
Collaborator

This should already be fixed. Can you confirm which revision of master of you're using?

@nyalldawson nyalldawson added the Feedback Waiting on the submitter for answers label Apr 5, 2022
@jakimowb
Copy link
Contributor Author

jakimowb commented Apr 5, 2022

Obviously I should pull the master more frequently. You are right, it's fixed. Thank's a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Feedback Waiting on the submitter for answers
Projects
None yet
Development

No branches or pull requests

2 participants