File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -670,14 +670,28 @@ void QgsOgrProvider::loadFields()
670670 default : varType = QVariant::String; // other unsupported, leave it as a string
671671 }
672672
673- mAttributeFields .append (
674- QgsField (
675- // TODO: fix this hack
673+ // TODO: fix this hack
676674#ifdef ANDROID
677- OGR_Fld_GetNameRef ( fldDef ),
675+ QString name = OGR_Fld_GetNameRef ( fldDef );
678676#else
679- mEncoding ->toUnicode ( OGR_Fld_GetNameRef ( fldDef ) ),
677+ QString name = mEncoding ->toUnicode ( OGR_Fld_GetNameRef ( fldDef ) );
680678#endif
679+
680+ if ( mAttributeFields .indexFromName ( name ) != -1 )
681+ {
682+
683+ QString tmpname = name + " _%1" ;
684+ int fix = 0 ;
685+
686+ while ( mAttributeFields .indexFromName ( name ) != -1 )
687+ {
688+ name = tmpname.arg ( ++fix );
689+ }
690+ }
691+
692+ mAttributeFields .append (
693+ QgsField (
694+ name,
681695 varType,
682696#ifdef ANDROID
683697 OGR_GetFieldTypeName ( ogrType ),
You can’t perform that action at this time.
0 commit comments