Skip to content

Commit

Permalink
Merge pull request #255 from rouault/master
Browse files Browse the repository at this point in the history
Fix errors in the usage of setlocale() and CPLGetConfigOption()
  • Loading branch information
timlinux committed Sep 28, 2012
2 parents aaa5040 + 82a22f0 commit 23352ce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/core/qgscoordinatereferencesystem.cpp
Expand Up @@ -900,7 +900,10 @@ void QgsCoordinateReferenceSystem::setDescription( QString theDescription )
}
void QgsCoordinateReferenceSystem::setProj4String( QString theProj4String )
{
const char *oldlocale = setlocale( LC_NUMERIC, NULL );
char *oldlocale = setlocale( LC_NUMERIC, NULL );
/* the next setlocale() invalides the return of previous setlocale() */
if (oldlocale != NULL)
oldlocale = strdup(oldlocale);

setlocale( LC_NUMERIC, "C" );
OSRDestroySpatialReference( mCRS );
Expand All @@ -916,6 +919,7 @@ void QgsCoordinateReferenceSystem::setProj4String( QString theProj4String )
#endif

setlocale( LC_NUMERIC, oldlocale );
free(oldlocale);
}
void QgsCoordinateReferenceSystem::setGeographicFlag( bool theGeoFlag )
{
Expand Down
4 changes: 3 additions & 1 deletion src/providers/gdal/qgsgdalprovider.cpp
Expand Up @@ -1377,7 +1377,7 @@ QString QgsGdalProvider::buildPyramids( QList<QgsRasterPyramid> const & theRaste
}

// are we using Erdas Imagine external overviews?
const char* myConfigUseRRD = CPLGetConfigOption( "USE_RRD", "NO" );
char* myConfigUseRRD = strdup(CPLGetConfigOption( "USE_RRD", "NO" ));
if ( theFormat == PyramidsErdas )
CPLSetConfigOption( "USE_RRD", "YES" );
else
Expand Down Expand Up @@ -1471,6 +1471,7 @@ QString QgsGdalProvider::buildPyramids( QList<QgsRasterPyramid> const & theRaste
//emit drawingProgress( 0, 0 );
// restore former USE_RRD config (Erdas)
CPLSetConfigOption( "USE_RRD", myConfigUseRRD );
free(myConfigUseRRD);
return "FAILED_NOT_SUPPORTED";
}
else
Expand All @@ -1487,6 +1488,7 @@ QString QgsGdalProvider::buildPyramids( QList<QgsRasterPyramid> const & theRaste

// restore former USE_RRD config (Erdas)
CPLSetConfigOption( "USE_RRD", myConfigUseRRD );
free(myConfigUseRRD);

QgsDebugMsg( "Pyramid overviews built" );

Expand Down

0 comments on commit 23352ce

Please sign in to comment.