From 740461a27bd31588696c723e97ea6696ca0c1f25 Mon Sep 17 00:00:00 2001 From: Howard Butler Date: Tue, 23 Oct 2012 12:59:56 -0500 Subject: [PATCH] try to trap conditions where Debug* is no longer available --- include/pdal/GDALUtils.hpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/include/pdal/GDALUtils.hpp b/include/pdal/GDALUtils.hpp index 5b6d1d6e4c..55cf0bcb41 100644 --- a/include/pdal/GDALUtils.hpp +++ b/include/pdal/GDALUtils.hpp @@ -63,8 +63,16 @@ class PDAL_DLL Debug static void CPL_STDCALL trampoline(::CPLErr code, int num, char const* msg) { -#if ((GDAL_VERSION_MAJOR == 1 && GDAL_VERSION_MINOR >= 9) || (GDAL_VERSION_MAJOR > 1)) - static_cast(CPLGetErrorHandlerUserData())->m_gdal_callback(code, num, msg); +#if ((GDAL_VERSION_MAJOR == 1 && GDAL_VERSION_MINOR >= 9) || (GDAL_VERSION_MAJOR > 1)) + + + Debug* debug = static_cast(CPLGetErrorHandlerUserData()); + if (!debug) + return; + + debug->m_gdal_callback(code, num, msg); + + if (!debug->m_log->get()) return; #else if (code == CE_Failure || code == CE_Fatal) { @@ -86,7 +94,6 @@ class PDAL_DLL Debug void log(::CPLErr code, int num, char const* msg); void error(::CPLErr code, int num, char const* msg); - private: boost::function m_gdal_callback; bool m_isDebug;