[Qgis-developer] Problems using QgsVectorLayer::selectedFeatures()

Federico J. Fernández federico.fernandez at gmail.com
Mon Feb 7 07:54:23 EST 2011


>
> On Mon, Feb 7, 2011 at 12:40 PM, Federico J. Fernández
> <federico.fernandez at gmail.com> wrote:
> >     QgsFeatureList &featureList = this->currentLayer->selectedFeatures();
>
> You only store reference to a temporary list returned by
> selectedFeatures(). That list is destroyed when that function
> terminates, so you have an invalid reference. Store the whole list
> instead, not just that reference:
>
> QgsFeatureList featureList = .... ;
>
> Your original post actually listed the correct version (without the
> reference '&'), that's why it wasn't clear where's your problem.
>
> By the way, QGIS contains a map tool for merging features (in
> src/app), so you could save your work by using that code instead of
> writing similar code again.
>
>
Sorry for the mistake Martin, it gives an exception with and without the &.

I know about the QGIS tool, my version is copied from that code, but without
some layer checks that are not neede in my application.

Thanks again for your help!

--
fede
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20110207/f120bbec/attachment-0001.html


More information about the Qgis-developer mailing list