Skip to content

Commit

Permalink
[ogr] Rename columns with non-unique name (Fix #8385)
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Jul 30, 2013
1 parent 8828ae1 commit 5414031
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/providers/ogr/qgsogrprovider.cpp
Expand Up @@ -670,14 +670,28 @@ void QgsOgrProvider::loadFields()
default: varType = QVariant::String; // other unsupported, leave it as a string
}

mAttributeFields.append(
QgsField(
//TODO: fix this hack
//TODO: fix this hack
#ifdef ANDROID
OGR_Fld_GetNameRef( fldDef ),
QString name = OGR_Fld_GetNameRef( fldDef );
#else
mEncoding->toUnicode( OGR_Fld_GetNameRef( fldDef ) ),
QString name = mEncoding->toUnicode( OGR_Fld_GetNameRef( fldDef ) );
#endif

if ( mAttributeFields.indexFromName( name ) != -1 )
{

QString tmpname = name + "_%1";
int fix = 0;

while ( mAttributeFields.indexFromName( name ) != -1 )
{
name = tmpname.arg( ++fix );
}
}

mAttributeFields.append(
QgsField(
name,
varType,
#ifdef ANDROID
OGR_GetFieldTypeName( ogrType ),
Expand Down

0 comments on commit 5414031

Please sign in to comment.