[QGIS-Developer] QgsFeatureSource::getFeatures - why returning Iterator by value instead of pointer ?

Martin Dobias wonder.sk at gmail.com
Sun Oct 17 12:13:10 PDT 2021


Hi Sandro

On Fri, Oct 15, 2021 at 5:32 PM Sandro Santilli <strk at kbt.io> wrote:

> My question is: why is a QgsFeatureIterator being constructed here,
> just for returning it as a value ?


If I remember correctly, that's mainly for convenience in the client code,
no need to deal with raw pointers that need to be deleted afterwards.
QgsFeatureIterator also adds implicit sharing, just like many other Qt
classes do (e.g. QString).


> Why not returning a pointer
> instead, to allow subclasses to return whatever derived class they want ?
>

Well, in that code snippet we are already in a subclass that returns the
derived class as wanted, so I am not sure if I understand your concern...

Regards
Martin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20211017/98154551/attachment.html>


More information about the QGIS-Developer mailing list