Skip to content

Commit f3f933d

Browse files
author
jef
committed
fix #1141 by fixing #1120 differently.
I still don't see why r8592 has an effect, except calling OSRImportFromProj4() in locale "C". Just setting LC_NUMERIC probably resolves the side effects leading to #1141 without reopening #1120. But there might be - even more subtle - side effects left - watch out. git-svn-id: http://svn.osgeo.org/qgis/trunk@8759 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 26833c5 commit f3f933d

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

src/core/qgsspatialrefsys.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,10 @@ bool QgsSpatialRefSys::loadFromDb(QString db, QString field, long id)
228228
mGeoFlag = (geo == 0 ? false : true);
229229
setMapUnits();
230230
mIsValidFlag = true;
231-
const char *oldlocale = setlocale(LC_ALL, NULL);
232-
setlocale(LC_ALL, "C");
231+
const char *oldlocale = setlocale(LC_NUMERIC, NULL);
232+
setlocale(LC_NUMERIC, "C");
233233
OSRImportFromProj4( mSRS, proj4String.toLatin1().constData() );
234-
setlocale(LC_ALL, oldlocale);
234+
setlocale(LC_NUMERIC, oldlocale);
235235
}
236236
else
237237
{
@@ -411,10 +411,10 @@ bool QgsSpatialRefSys::createFromProj4 (const QString theProj4String)
411411
if (!myRecord.empty())
412412
{
413413
// Success! We have found the proj string by swapping the lat_1 and lat_2
414-
const char *oldlocale = setlocale(LC_ALL, NULL);
415-
setlocale(LC_ALL, "C");
414+
const char *oldlocale = setlocale(LC_NUMERIC, NULL);
415+
setlocale(LC_NUMERIC, "C");
416416
OSRImportFromProj4(mSRS, theProj4StringModified.toLatin1().constData() );
417-
setlocale(LC_ALL, oldlocale);
417+
setlocale(LC_NUMERIC, oldlocale);
418418
mySrsId=myRecord["srs_id"].toLong();
419419
QgsDebugMsg("QgsSpatialRefSys::createFromProj4 proj4string match search for srsid returned srsid: " + QString::number(mySrsId));
420420
if (mySrsId > 0)
@@ -664,10 +664,10 @@ void QgsSpatialRefSys::setDescription (QString theDescription)
664664
}
665665
void QgsSpatialRefSys::setProj4String (QString theProj4String)
666666
{
667-
const char *oldlocale = setlocale(LC_ALL, NULL);
668-
setlocale(LC_ALL, "C");
667+
const char *oldlocale = setlocale(LC_NUMERIC, NULL);
668+
setlocale(LC_NUMERIC, "C");
669669
mIsValidFlag = OSRImportFromProj4(mSRS, theProj4String.toLatin1().constData() )==OGRERR_NONE;
670-
setlocale(LC_ALL, oldlocale);
670+
setlocale(LC_NUMERIC, oldlocale);
671671
}
672672
void QgsSpatialRefSys::setGeographicFlag (bool theGeoFlag)
673673
{

src/plugins/grass/qgsgrassnewmapset.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -473,10 +473,10 @@ void QgsGrassNewMapset::setGrassProjection()
473473
OGRSpatialReferenceH hSRS = NULL;
474474
hSRS = OSRNewSpatialReference(NULL);
475475
int errcode;
476-
const char *oldlocale = setlocale(LC_ALL, NULL);
477-
setlocale(LC_ALL, "C");
476+
const char *oldlocale = setlocale(LC_NUMERIC, NULL);
477+
setlocale(LC_NUMERIC, "C");
478478
errcode = OSRImportFromProj4(hSRS, proj4.ascii());
479-
setlocale(LC_ALL, oldlocale);
479+
setlocale(LC_NUMERIC, oldlocale);
480480
if ( errcode!=OGRERR_NONE )
481481
{
482482
std::cerr << "OGR can't parse PROJ.4-style parameter string:\n" << proj4.ascii()

src/providers/grass/qgsgrassprovider.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1253,8 +1253,8 @@ QgsSpatialRefSys QgsGrassProvider::getSRS()
12531253
QgsGrass::resetError();
12541254
QgsGrass::setLocation ( mGisdbase, mLocation );
12551255

1256-
char *oldlocale = setlocale(LC_ALL, NULL);
1257-
setlocale(LC_ALL, "C");
1256+
const char *oldlocale = setlocale(LC_NUMERIC, NULL);
1257+
setlocale(LC_NUMERIC, "C");
12581258

12591259
if ( setjmp(QgsGrass::fatalErrorEnv()) == 0 )
12601260
{
@@ -1263,7 +1263,7 @@ QgsSpatialRefSys QgsGrassProvider::getSRS()
12631263
QgsGrass::clearErrorEnv();
12641264

12651265
if ( QgsGrass::getError() == QgsGrass::FATAL ) {
1266-
setlocale(LC_ALL, oldlocale);
1266+
setlocale(LC_NUMERIC, oldlocale);
12671267
QgsDebugMsg(QString("Cannot get default window: %1").arg(QgsGrass::getErrorMessage()));
12681268
return QgsSpatialRefSys();
12691269
}
@@ -1276,7 +1276,7 @@ QgsSpatialRefSys QgsGrassProvider::getSRS()
12761276
free ( wkt);
12771277
}
12781278

1279-
setlocale(LC_ALL, oldlocale);
1279+
setlocale(LC_NUMERIC, oldlocale);
12801280

12811281
QgsSpatialRefSys srs;
12821282
srs.createFromWkt(WKT);

0 commit comments

Comments
 (0)