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.
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:
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/777Almost 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.