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

Martin Dobias wonder.sk at gmail.com
Mon Feb 7 04:07:44 EST 2011


On Thu, Feb 3, 2011 at 3:46 PM, Federico J. Fernández
<federico.fernandez at gmail.com> wrote:
>>
>> In what context do you call the selectedFeatures() method, what is the
>> expected result and what do you get instead?
>
> I get the correct values.
>
> I call it in a slot that is called when the user clicks the map with an
> EmitPoint tool. But when the method ends and then the QList is destroyed,
> the application aborts. I think that it has to do with the ownership of the
> features, but it is strange because I'm getting a copy of the list... I
> can't still figure out what is the problem. If I use a newly allocated
> pointer for the List, everything works fine until I delete that object.

I'm confused - you don't have to allocate any pointers for the list.
The QList class uses implicit sharing of data (like many other qt
classes), so the list can be passed by value very cheaply. Please
paste the code of the whole method if it's not too long and indicate
on what line the application crashes.


Martin


More information about the Qgis-developer mailing list