Skip to content

Commit

Permalink
Call OGR_Fld_SetSubType before OGR_L_CreateField
Browse files Browse the repository at this point in the history
  • Loading branch information
pblottiere committed Nov 15, 2017
1 parent caf0cf7 commit 6465af3
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/core/qgsvectorfilewriter.cpp
Expand Up @@ -579,6 +579,15 @@ void QgsVectorFileWriter::init( QString vectorFileName,
OGR_Fld_SetPrecision( fld.get(), ogrPrecision );
}

switch ( attrField.type() )
{
case QVariant::Bool:
OGR_Fld_SetSubType( fld.get(), OFSTBoolean );
break;
default:
break;
}

// create the field
QgsDebugMsg( "creating field " + attrField.name() +
" type " + QString( QVariant::typeToName( attrField.type() ) ) +
Expand Down Expand Up @@ -2047,7 +2056,6 @@ gdal::ogr_feature_unique_ptr QgsVectorFileWriter::createFeature( const QgsFeatur
break;
case QVariant::Bool:
OGR_F_SetFieldInteger( poFeature.get(), ogrField, attrValue.toInt() );
OGR_Fld_SetSubType( OGR_F_GetFieldDefnRef( poFeature.get(), ogrField ), OFSTBoolean );
break;
case QVariant::String:
OGR_F_SetFieldString( poFeature.get(), ogrField, mCodec->fromUnicode( attrValue.toString() ).constData() );
Expand Down

0 comments on commit 6465af3

Please sign in to comment.