File tree Expand file tree Collapse file tree 2 files changed +7
-0
lines changed
Expand file tree Collapse file tree 2 files changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -196,6 +196,10 @@ class CORE_EXPORT QgsFields
196196 inline int count () const { return mFields .count (); }
197197 // ! Return number of items
198198 inline int size () const { return mFields .count (); }
199+ // ! Return if a field index is valid
200+ // ! @param i Index of the field which needs to be checked
201+ // ! @return True if the field exists
202+ inline bool exists ( int i ) const { return i >= 0 && i < mFields .count (); }
199203
200204 // ! Get field at particular index (must be in range 0..N-1)
201205 inline const QgsField& operator []( int i ) const { return mFields [i].field ; }
Original file line number Diff line number Diff line change @@ -351,6 +351,9 @@ void QgsVectorLayerFeatureIterator::prepareJoins()
351351
352352 for ( QgsAttributeList::const_iterator attIt = fetchAttributes.constBegin (); attIt != fetchAttributes.constEnd (); ++attIt )
353353 {
354+ if ( !fields.exists ( *attIt ) )
355+ continue ;
356+
354357 if ( fields.fieldOrigin ( *attIt ) != QgsFields::OriginJoin )
355358 continue ;
356359
You can’t perform that action at this time.
0 commit comments