Skip to content
Permalink
Browse files

[OGR] Handle mFirstFieldIsFid in renameAttributes

  • Loading branch information
nyalldawson committed Jun 1, 2016
1 parent 831f4c1 commit 732b1cb1720cfb5f2a30d35616e5df8be5bc1c76
Showing with 13 additions and 1 deletion.
  1. +13 −1 src/providers/ogr/qgsogrprovider.cpp
@@ -1339,14 +1339,26 @@ bool QgsOgrProvider::renameAttributes( const QgsFieldNameMap& renamedAttributes
result = false;
continue;
}
int ogrFieldIndex = fieldIndex;
if ( mFirstFieldIsFid )
{
ogrFieldIndex -= 1;
if ( ogrFieldIndex < 0 )
{
pushError( tr( "Invalid attribute index" ) );
result = false;
continue;
}
}

//type does not matter, it will not be used
OGRFieldDefnH fld = OGR_Fld_Create( mEncoding->fromUnicode( renameIt.value() ), OFTReal );
if ( OGR_L_AlterFieldDefn( ogrLayer, fieldIndex, fld, ALTER_NAME_FLAG ) != OGRERR_NONE )
if ( OGR_L_AlterFieldDefn( ogrLayer, ogrFieldIndex, fld, ALTER_NAME_FLAG ) != OGRERR_NONE )
{
pushError( tr( "OGR error renaming field %1: %2" ).arg( fieldIndex ).arg( CPLGetLastErrorMsg() ) );
result = false;
}
OGR_Fld_Destroy( fld );
}
loadFields();
return result;

0 comments on commit 732b1cb

Please sign in to comment.
You can’t perform that action at this time.