[QGIS Commit] r8759 - in trunk/qgis/src: core plugins/grass providers/grass

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sat Jul 12 05:18:53 EDT 2008


Author: jef
Date: 2008-07-12 05:18:52 -0400 (Sat, 12 Jul 2008)
New Revision: 8759

Modified:
   trunk/qgis/src/core/qgsspatialrefsys.cpp
   trunk/qgis/src/plugins/grass/qgsgrassnewmapset.cpp
   trunk/qgis/src/providers/grass/qgsgrassprovider.cpp
Log:
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.



Modified: trunk/qgis/src/core/qgsspatialrefsys.cpp
===================================================================
--- trunk/qgis/src/core/qgsspatialrefsys.cpp	2008-07-11 23:04:43 UTC (rev 8758)
+++ trunk/qgis/src/core/qgsspatialrefsys.cpp	2008-07-12 09:18:52 UTC (rev 8759)
@@ -228,10 +228,10 @@
     mGeoFlag = (geo == 0 ? false : true);
     setMapUnits();
     mIsValidFlag = true;
-    const char *oldlocale = setlocale(LC_ALL, NULL);
-    setlocale(LC_ALL, "C");
+    const char *oldlocale = setlocale(LC_NUMERIC, NULL);
+    setlocale(LC_NUMERIC, "C");
     OSRImportFromProj4( mSRS, proj4String.toLatin1().constData() );
-    setlocale(LC_ALL, oldlocale);
+    setlocale(LC_NUMERIC, oldlocale);
   }
   else
   {
@@ -411,10 +411,10 @@
       if (!myRecord.empty())
       {
         // Success!  We have found the proj string by swapping the lat_1 and lat_2
-        const char *oldlocale = setlocale(LC_ALL, NULL);
-        setlocale(LC_ALL, "C");
+        const char *oldlocale = setlocale(LC_NUMERIC, NULL);
+        setlocale(LC_NUMERIC, "C");
         OSRImportFromProj4(mSRS, theProj4StringModified.toLatin1().constData() );
-        setlocale(LC_ALL, oldlocale); 
+        setlocale(LC_NUMERIC, oldlocale); 
         mySrsId=myRecord["srs_id"].toLong();
         QgsDebugMsg("QgsSpatialRefSys::createFromProj4 proj4string match search for srsid returned srsid: " + QString::number(mySrsId));
         if (mySrsId > 0)
@@ -664,10 +664,10 @@
 }
 void QgsSpatialRefSys::setProj4String (QString theProj4String)
 {
-  const char *oldlocale = setlocale(LC_ALL, NULL);
-  setlocale(LC_ALL, "C");
+  const char *oldlocale = setlocale(LC_NUMERIC, NULL);
+  setlocale(LC_NUMERIC, "C");
   mIsValidFlag = OSRImportFromProj4(mSRS, theProj4String.toLatin1().constData() )==OGRERR_NONE;
-  setlocale(LC_ALL, oldlocale);
+  setlocale(LC_NUMERIC, oldlocale);
 }
 void QgsSpatialRefSys::setGeographicFlag (bool theGeoFlag)
 {

Modified: trunk/qgis/src/plugins/grass/qgsgrassnewmapset.cpp
===================================================================
--- trunk/qgis/src/plugins/grass/qgsgrassnewmapset.cpp	2008-07-11 23:04:43 UTC (rev 8758)
+++ trunk/qgis/src/plugins/grass/qgsgrassnewmapset.cpp	2008-07-12 09:18:52 UTC (rev 8759)
@@ -473,10 +473,10 @@
     OGRSpatialReferenceH hSRS = NULL;
     hSRS = OSRNewSpatialReference(NULL);
     int errcode;
-    const char *oldlocale = setlocale(LC_ALL, NULL);
-    setlocale(LC_ALL, "C");
+    const char *oldlocale = setlocale(LC_NUMERIC, NULL);
+    setlocale(LC_NUMERIC, "C");
     errcode = OSRImportFromProj4(hSRS, proj4.ascii());
-    setlocale(LC_ALL, oldlocale);
+    setlocale(LC_NUMERIC, oldlocale);
     if ( errcode!=OGRERR_NONE )
     {
       std::cerr << "OGR can't parse PROJ.4-style parameter string:\n" << proj4.ascii()

Modified: trunk/qgis/src/providers/grass/qgsgrassprovider.cpp
===================================================================
--- trunk/qgis/src/providers/grass/qgsgrassprovider.cpp	2008-07-11 23:04:43 UTC (rev 8758)
+++ trunk/qgis/src/providers/grass/qgsgrassprovider.cpp	2008-07-12 09:18:52 UTC (rev 8759)
@@ -1253,8 +1253,8 @@
   QgsGrass::resetError();
   QgsGrass::setLocation ( mGisdbase, mLocation ); 
 
-  char *oldlocale = setlocale(LC_ALL, NULL);
-  setlocale(LC_ALL, "C");
+  const char *oldlocale = setlocale(LC_NUMERIC, NULL);
+  setlocale(LC_NUMERIC, "C");
 
   if ( setjmp(QgsGrass::fatalErrorEnv()) == 0 )
   {
@@ -1263,7 +1263,7 @@
   QgsGrass::clearErrorEnv();
 
   if ( QgsGrass::getError() == QgsGrass::FATAL ) {
-    setlocale(LC_ALL, oldlocale);
+    setlocale(LC_NUMERIC, oldlocale);
     QgsDebugMsg(QString("Cannot get default window: %1").arg(QgsGrass::getErrorMessage()));
     return QgsSpatialRefSys();
   }
@@ -1276,7 +1276,7 @@
     free ( wkt);
   }
 
-  setlocale(LC_ALL, oldlocale);
+  setlocale(LC_NUMERIC, oldlocale);
 
   QgsSpatialRefSys srs;
   srs.createFromWkt(WKT);



More information about the QGIS-commit mailing list