Skip to content

Commit

Permalink
fix #3137
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15238 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Feb 21, 2011
1 parent 498c8ee commit f708fe7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/core/qgsvectorfilewriter.cpp
Expand Up @@ -90,6 +90,7 @@ QgsVectorFileWriter::QgsVectorFileWriter(
vectorFileName += ".shp";
}

#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM < 1700
// check for unique fieldnames
QSet<QString> fieldNames;
QgsFieldMap::const_iterator fldIt;
Expand All @@ -105,6 +106,7 @@ QgsVectorFileWriter::QgsVectorFileWriter(
}
fieldNames << name;
}
#endif

deleteShapeFile( vectorFileName );
}
Expand Down Expand Up @@ -329,6 +331,7 @@ QgsVectorFileWriter::QgsVectorFileWriter(
int ogrIdx = OGR_FD_GetFieldIndex( defn, mCodec->fromUnicode( attrField.name() ) );
if ( ogrIdx < 0 )
{
#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM < 1700
// if we didn't find our new column, assume it's name was truncated and
// it was the last one added (like for shape files)
int fieldCount = OGR_FD_GetFieldCount( defn );
Expand All @@ -343,6 +346,10 @@ QgsVectorFileWriter::QgsVectorFileWriter(
ogrIdx = fieldCount - 1;
}
}
#else
// GDAL 1.7 not just truncates, but launders more aggressivly.
ogrIdx = OGR_FD_GetFieldCount( defn ) - 1;
#endif

if ( ogrIdx < 0 )
{
Expand Down

0 comments on commit f708fe7

Please sign in to comment.