Skip to content
Permalink
Browse files
fix #2933
git-svn-id: http://svn.osgeo.org/qgis/trunk@14066 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Aug 11, 2010
1 parent be37487 commit 36c894c0566ed3307d123b9d6e5dd036a1625f11
Showing with 14 additions and 2 deletions.
  1. +14 −2 src/core/qgsvectorfilewriter.cpp
@@ -185,6 +185,8 @@ QgsVectorFileWriter::QgsVectorFileWriter(
return;
}

OGRFeatureDefnH defn = OGR_L_GetLayerDefn( mLayer );

QgsDebugMsg( "created layer" );

// create the fields
@@ -193,7 +195,6 @@ QgsVectorFileWriter::QgsVectorFileWriter(
mFields = fields;
mAttrIdxToOgrIdx.clear();

int ogrIdx = 0;
QgsFieldMap::const_iterator fldIt;
for ( fldIt = fields.begin(); fldIt != fields.end(); ++fldIt )
{
@@ -261,7 +262,18 @@ QgsVectorFileWriter::QgsVectorFileWriter(
return;
}

mAttrIdxToOgrIdx.insert( fldIt.key(), ogrIdx++ );
int ogrIdx = OGR_FD_GetFieldIndex( defn, mCodec->fromUnicode( attrField.name() ) );
if ( ogrIdx < 0 )
{
QgsDebugMsg( "error creating field " + attrField.name() );
mErrorMessage = QObject::tr( "created field %1 not found (OGR error: %2)" )
.arg( attrField.name() )
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ) );
mError = ErrAttributeCreationFailed;
return;
}

mAttrIdxToOgrIdx.insert( fldIt.key(), ogrIdx );
}

QgsDebugMsg( "Done creating fields" );

0 comments on commit 36c894c

Please sign in to comment.