qgis / qgis4.0_api

Tracker for QGIS 4.0 API related issues and developer discussion
3 stars 1 forks source link

Remove geometry pointer accessors from QgsFeature #13

Closed nyalldawson closed 7 years ago

nyalldawson commented 8 years ago

Most of the heavy lifting for this is already done, but the accessors in QgsFeature for retrieving pointers to the geometry should be removed. Instead, we should have a single getter:

QgsGeometry geometry () const

And a setter:

void setGeometry( const QgsGeometry& geometry )

These would take advantage of the (already implemented) implicit sharing of geometries, and avoid the current dangerous use of pointers to geometries. Amongst other issues, this would simplify the API for PyQGIS (no more need for g=QgsGeometry( feat.geometry() ) c++ style code) and finally allow us to fix http://hub.qgis.org/issues/777

Almost all of the c++ code now uses the constGeometry() getter rather than modifying geometries in place, so changing this behaviour should be straightforward for the c++ code. The core python code would also need to be updated, and this is likely to be more work as it would require removal of any in place modifiers.

nyalldawson commented 7 years ago

Done in https://github.com/qgis/QGIS/commit/bd7d913379b68a8104608b1afab4d380e4edc26b