Skip to content
Permalink
Browse files

Free all GDAL and OGR resources when both are used

  • Loading branch information...
rouault committed Sep 5, 2019
1 parent d7b11f3 commit 9d8ce59bbdb409e61b067b152f21a59f8a7d6f7a
Showing with 17 additions and 10 deletions.
  1. +0 −9 mapgdal.c
  2. +0 −1 mapogr.cpp
  3. +17 −0 maputil.c
@@ -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
}

/************************************************************************/
@@ -5523,7 +5523,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>
@@ -1956,6 +1960,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 9d8ce59

Please sign in to comment.
You can’t perform that action at this time.