Skip to content

Commit 612576c

Browse files
committedFeb 3, 2019
Deprecate QgsGeometry::set for usage in Python
When a new QgsAbstractGeometry is set on a geometry object, the previous child is deleted. If the previous object was constructed by Python, it's wrapper will still be alive for as long as the QgsGeometry is alive. If a new QgsAbstractGeometry is constructed at the same memory address as the old one, the wrapper will be reused with wrong type (and other) information, leading to all kind of weird issues. See also https://www.riverbankcomputing.com/pipermail/pyqt/2019-January/041251.html
1 parent 4a44306 commit 612576c

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed
 

‎python/core/auto_generated/geometry/qgsgeometry.sip.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,12 @@ Sets the underlying geometry store. Ownership of geometry is transferred.
133133

134134
In QGIS 2.x this method was named setGeometry().
135135

136+
.. note::
137+
138+
This method is deprecated for usage in Python and will be removed from Python bindings with QGIS 4.
139+
Using this method will confuse Python's memory management and type information system.
140+
Better create a new QgsGeometry object instead.
141+
136142
.. seealso:: :py:func:`get`
137143

138144
.. seealso:: :py:func:`constGet`

‎src/core/geometry/qgsgeometry.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,9 @@ class CORE_EXPORT QgsGeometry
196196
* Sets the underlying geometry store. Ownership of geometry is transferred.
197197
*
198198
* \note In QGIS 2.x this method was named setGeometry().
199+
* \note This method is deprecated for usage in Python and will be removed from Python bindings with QGIS 4.
200+
* Using this method will confuse Python's memory management and type information system.
201+
* Better create a new QgsGeometry object instead.
199202
*
200203
* \see get()
201204
* \see constGet()

0 commit comments

Comments
 (0)
Please sign in to comment.