File tree Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -259,8 +259,12 @@ void QgsFields::remove( int fieldIdx )
259
259
if ( !exists ( fieldIdx ) )
260
260
return ;
261
261
262
- d->nameToIndex .remove ( d->fields [fieldIdx].field .name () );
263
262
d->fields .remove ( fieldIdx );
263
+ d->nameToIndex .clear ();
264
+ for ( int idx = 0 ; idx < count (); ++idx )
265
+ {
266
+ d->nameToIndex .insert ( d->fields [idx].field .name (), idx );
267
+ }
264
268
}
265
269
266
270
void QgsFields::extend ( const QgsFields& other )
Original file line number Diff line number Diff line change @@ -230,6 +230,7 @@ void TestQgsFields::remove()
230
230
fields.remove ( 0 );
231
231
QCOMPARE ( fields.count (), 1 );
232
232
QCOMPARE ( fields.at ( 0 ).name (), QString ( " testfield2" ) );
233
+ QCOMPARE ( fields.indexFromName (QString ( " testfield2" )), 0 );
233
234
}
234
235
235
236
void TestQgsFields::extend ()
You can’t perform that action at this time.
0 commit comments