Skip to content

Commit

Permalink
Free all GDAL and OGR resources when both are used
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Sep 11, 2019
1 parent 836b4a7 commit 271078a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
9 changes: 0 additions & 9 deletions mapgdal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

/************************************************************************/
Expand Down
1 change: 0 additions & 1 deletion mapogr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5522,7 +5522,6 @@ void msOGRCleanup( void )
ACQUIRE_OGR_LOCK;
if( bOGRDriversRegistered == MS_TRUE ) {
CPLPopErrorHandler();
OGRCleanupAll();
bOGRDriversRegistered = MS_FALSE;
}
RELEASE_OGR_LOCK;
Expand Down
17 changes: 17 additions & 0 deletions maputil.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 271078a

Please sign in to comment.