@@ -53,9 +53,11 @@ bool QgsDelimitedTextFeatureIterator::nextFeature( QgsFeature& feature )
53
53
while ( true )
54
54
{
55
55
QgsDelimitedTextFile::Status status = P->mFile ->nextRecord ( tokens );
56
- int fid = P->mFile ->recordLineNumber ();
57
56
if ( status == QgsDelimitedTextFile::RecordEOF ) break ;
58
57
if ( status != QgsDelimitedTextFile::RecordOk ) continue ;
58
+
59
+ int fid = P->mFile ->recordLineNumber ();
60
+ if ( mRequest .filterType () == QgsFeatureRequest::FilterFid && fid != mRequest .filterFid ()) continue ;
59
61
if ( P->recordIsEmpty ( tokens ) ) continue ;
60
62
61
63
while ( tokens.size () < P->mFieldCount )
@@ -98,8 +100,6 @@ bool QgsDelimitedTextFeatureIterator::nextFeature( QgsFeature& feature )
98
100
for ( QgsAttributeList::const_iterator i = attrs.begin (); i != attrs.end (); ++i )
99
101
{
100
102
int fieldIdx = *i;
101
- if ( fieldIdx < 0 || fieldIdx >= P->attributeColumns .count () )
102
- continue ; // ignore non-existant fields
103
103
fetchAttribute ( feature, fieldIdx, tokens );
104
104
}
105
105
}
@@ -209,7 +209,10 @@ bool QgsDelimitedTextFeatureIterator::boundsCheck( QgsGeometry *geom )
209
209
210
210
void QgsDelimitedTextFeatureIterator::fetchAttribute ( QgsFeature& feature, int fieldIdx, const QStringList& tokens )
211
211
{
212
- const QString &value = tokens[P->attributeColumns [fieldIdx]];
212
+ if ( fieldIdx < 0 || fieldIdx >= P->attributeColumns .count ()) return ;
213
+ int column = P->attributeColumns [fieldIdx];
214
+ if ( column < 0 || column >= tokens.count ()) return ;
215
+ const QString &value = tokens[column];
213
216
QVariant val;
214
217
switch ( P->attributeFields [fieldIdx].type () )
215
218
{
0 commit comments