[Qgis-developer] Problems using QgsVectorLayer::selectedFeatures()
    Martin Dobias 
    wonder.sk at gmail.com
       
    Mon Feb  7 07:48:25 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.
Martin
    
    
More information about the Qgis-developer
mailing list