Skip to content

Commit c64a051

Browse files
committed
ogr provider: write numeric data in C locale (fixes #8332)
1 parent 5bee172 commit c64a051

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/providers/ogr/qgsogrprovider.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,12 @@ bool QgsOgrProvider::addFeature( QgsFeature& f )
951951

952952
const QgsAttributes& attrs = f.attributes();
953953

954+
const char *oldlocale = setlocale( LC_NUMERIC, NULL );
955+
if ( oldlocale )
956+
oldlocale = strdup( oldlocale );
957+
958+
setlocale( LC_NUMERIC, "C" );
959+
954960
//add possible attribute information
955961
for ( int targetAttributeId = 0; targetAttributeId < attrs.count(); ++targetAttributeId )
956962
{
@@ -1025,6 +1031,9 @@ bool QgsOgrProvider::addFeature( QgsFeature& f )
10251031
f.setFeatureId( OGR_F_GetFID( feature ) );
10261032
}
10271033
OGR_F_Destroy( feature );
1034+
1035+
setlocale( LC_NUMERIC, oldlocale );
1036+
10281037
return returnValue;
10291038
}
10301039

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

11561165
const QgsAttributeMap& attr = it.value();
11571166

1167+
const char *oldlocale = setlocale( LC_NUMERIC, NULL );
1168+
if ( oldlocale )
1169+
oldlocale = strdup( oldlocale );
1170+
setlocale( LC_NUMERIC, "C" );
1171+
11581172
for ( QgsAttributeMap::const_iterator it2 = attr.begin(); it2 != attr.end(); ++it2 )
11591173
{
11601174
int f = it2.key();
@@ -1215,6 +1229,8 @@ bool QgsOgrProvider::changeAttributeValues( const QgsChangedAttributesMap & attr
12151229
{
12161230
pushError( tr( "OGR error setting feature %1: %2" ).arg( fid ).arg( CPLGetLastErrorMsg() ) );
12171231
}
1232+
1233+
setlocale( LC_NUMERIC, oldlocale );
12181234
}
12191235

12201236
if ( OGR_L_SyncToDisk( ogrLayer ) != OGRERR_NONE )

0 commit comments

Comments
 (0)