Skip to content

Commit

Permalink
ogr provider: write numeric data in C locale (fixes #8332)
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Feb 12, 2014
1 parent 5bee172 commit c64a051
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/providers/ogr/qgsogrprovider.cpp
Expand Up @@ -951,6 +951,12 @@ bool QgsOgrProvider::addFeature( QgsFeature& f )

const QgsAttributes& attrs = f.attributes();

const char *oldlocale = setlocale( LC_NUMERIC, NULL );
if ( oldlocale )
oldlocale = strdup( oldlocale );

setlocale( LC_NUMERIC, "C" );

//add possible attribute information
for ( int targetAttributeId = 0; targetAttributeId < attrs.count(); ++targetAttributeId )
{
Expand Down Expand Up @@ -1025,6 +1031,9 @@ bool QgsOgrProvider::addFeature( QgsFeature& f )
f.setFeatureId( OGR_F_GetFID( feature ) );
}
OGR_F_Destroy( feature );

setlocale( LC_NUMERIC, oldlocale );

return returnValue;
}

Expand Down Expand Up @@ -1155,6 +1164,11 @@ bool QgsOgrProvider::changeAttributeValues( const QgsChangedAttributesMap & attr

const QgsAttributeMap& attr = it.value();

const char *oldlocale = setlocale( LC_NUMERIC, NULL );
if ( oldlocale )
oldlocale = strdup( oldlocale );
setlocale( LC_NUMERIC, "C" );

for ( QgsAttributeMap::const_iterator it2 = attr.begin(); it2 != attr.end(); ++it2 )
{
int f = it2.key();
Expand Down Expand Up @@ -1215,6 +1229,8 @@ bool QgsOgrProvider::changeAttributeValues( const QgsChangedAttributesMap & attr
{
pushError( tr( "OGR error setting feature %1: %2" ).arg( fid ).arg( CPLGetLastErrorMsg() ) );
}

setlocale( LC_NUMERIC, oldlocale );
}

if ( OGR_L_SyncToDisk( ogrLayer ) != OGRERR_NONE )
Expand Down

0 comments on commit c64a051

Please sign in to comment.