Skip to content

Commit

Permalink
Deprecate QgsGeometry::set for usage in Python
Browse files Browse the repository at this point in the history
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
  • Loading branch information
m-kuhn committed Feb 3, 2019
1 parent 4a44306 commit 612576c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions python/core/auto_generated/geometry/qgsgeometry.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ Sets the underlying geometry store. Ownership of geometry is transferred.

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

.. note::

This method is deprecated for usage in Python and will be removed from Python bindings with QGIS 4.
Using this method will confuse Python's memory management and type information system.
Better create a new QgsGeometry object instead.

.. seealso:: :py:func:`get`

.. seealso:: :py:func:`constGet`
Expand Down
3 changes: 3 additions & 0 deletions src/core/geometry/qgsgeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ class CORE_EXPORT QgsGeometry
* Sets the underlying geometry store. Ownership of geometry is transferred.
*
* \note In QGIS 2.x this method was named setGeometry().
* \note This method is deprecated for usage in Python and will be removed from Python bindings with QGIS 4.
* Using this method will confuse Python's memory management and type information system.
* Better create a new QgsGeometry object instead.
*
* \see get()
* \see constGet()
Expand Down

0 comments on commit 612576c

Please sign in to comment.