Skip to content
Permalink
Browse files
Free all GDAL and OGR resources when both are used
  • Loading branch information
rouault committed Sep 11, 2019
1 parent 836b4a7 commit 271078a6a8b564d7a3d6d260dc83003be955fea2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
@@ -105,19 +105,10 @@ void msGDALCleanup( void )
while( iRepeat-- )
CPLPopErrorHandler();

#if GDAL_RELEASE_DATE > 20021001
GDALDestroyDriverManager();
#endif

msReleaseLock( TLOCK_GDAL );

bGDALInitialized = 0;
}

#if GDAL_VERSION_MAJOR >= 3 || (GDAL_VERSION_MAJOR == 2 && GDAL_VERSION_MINOR == 4)
/* Cleanup some GDAL global resources in particular */
GDALDestroy();
#endif
}

/************************************************************************/
@@ -5522,7 +5522,6 @@ void msOGRCleanup( void )
ACQUIRE_OGR_LOCK;
if( bOGRDriversRegistered == MS_TRUE ) {
CPLPopErrorHandler();
OGRCleanupAll();
bOGRDriversRegistered = MS_FALSE;
}
RELEASE_OGR_LOCK;
@@ -39,6 +39,10 @@
#include "mapcopy.h"
#include "mapows.h"

#if defined(USE_OGR) || defined(USE_GDAL)
#include "gdal.h"
#endif

#if defined(_WIN32) && !defined(__CYGWIN__)
# include <windows.h>
# include <tchar.h>
@@ -2055,6 +2059,19 @@ void msCleanup()
#ifdef USE_GDAL
msGDALCleanup();
#endif

/* Release both GDAL and OGR resources */
#if defined(USE_OGR) || defined(USE_GDAL)
msAcquireLock( TLOCK_GDAL );
#if GDAL_VERSION_MAJOR >= 3 || (GDAL_VERSION_MAJOR == 2 && GDAL_VERSION_MINOR == 4)
/* Cleanup some GDAL global resources in particular */
GDALDestroy();
#else
GDALDestroyDriverManager();
#endif
msReleaseLock( TLOCK_GDAL );
#endif

#ifdef USE_PROJ
# if PJ_VERSION >= 480
pj_clear_initcache();

0 comments on commit 271078a

Please sign in to comment.