From 515fbf0da5d7ccdbd3e869f84b5b0d6d2f85fdcf Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Wed, 11 Sep 2024 00:03:03 +0200 Subject: [PATCH] Fix build issue of external code including gdal_priv.h with MSVC (master only) MSVC complains about "use of undefined type 'GDALDoublePointsCache'" since presumably it tries to locate the destructor of GDALDoublePointsCache, to which it doesn't have access --- gcore/gdal_priv.h | 2 +- gcore/gdalrasterband.cpp | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/gcore/gdal_priv.h b/gcore/gdal_priv.h index dcb80a3f203e..421367884f0a 100644 --- a/gcore/gdal_priv.h +++ b/gcore/gdal_priv.h @@ -1625,7 +1625,7 @@ class CPL_DLL GDALRasterBand : public GDALMajorObject void InitRWLock(); void SetValidPercent(GUIntBig nSampleCount, GUIntBig nValidCount); - mutable std::unique_ptr m_oPointsCache{}; + mutable GDALDoublePointsCache *m_poPointsCache = nullptr; //! @endcond diff --git a/gcore/gdalrasterband.cpp b/gcore/gdalrasterband.cpp index 651051edb2c9..3d522db99d7c 100644 --- a/gcore/gdalrasterband.cpp +++ b/gcore/gdalrasterband.cpp @@ -107,6 +107,8 @@ GDALRasterBand::~GDALRasterBand() InvalidateMaskBand(); nBand = -nBand; + + delete m_poPointsCache; } /************************************************************************/ @@ -9398,11 +9400,11 @@ CPLErr GDALRasterBand::InterpolateAtPoint(double dfPixel, double dfLine, } GDALRasterBand *pBand = const_cast(this); - if (!m_oPointsCache) - m_oPointsCache = std::make_unique(); + if (!m_poPointsCache) + m_poPointsCache = new GDALDoublePointsCache(); const bool res = - GDALInterpolateAtPoint(pBand, eInterpolation, m_oPointsCache->cache, + GDALInterpolateAtPoint(pBand, eInterpolation, m_poPointsCache->cache, dfPixel, dfLine, pdfRealValue, pdfImagValue); return res ? CE_None : CE_Failure;