sci-libs/gdal: Fix build with >=app-text/poppler-22.03.0

Closes: https://bugs.gentoo.org/834536
Package-Manager: Portage-3.0.30, Repoman-3.0.3
Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
This commit is contained in:
Andreas Sturmlechner
2022-03-07 17:41:08 +01:00
parent cad26fcc14
commit 6399fdc2f4
2 changed files with 56 additions and 2 deletions

View File

@@ -0,0 +1,54 @@
From 17e98757e78969a199d1d6318f53d088da192191 Mon Sep 17 00:00:00 2001
From: Even Rouault <even.rouault@spatialys.com>
Date: Fri, 18 Feb 2022 22:47:01 +0100
Subject: [PATCH] PDF: fix build against Poppler > 22.2
---
frmts/pdf/pdfdataset.cpp | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/frmts/pdf/pdfdataset.cpp b/frmts/pdf/pdfdataset.cpp
index 22238bd74822..08f8e31c86a7 100644
--- a/frmts/pdf/pdfdataset.cpp
+++ b/frmts/pdf/pdfdataset.cpp
@@ -4241,8 +4241,6 @@ PDFDataset *PDFDataset::Open( GDALOpenInfo * poOpenInfo )
#ifdef HAVE_POPPLER
if(bUseLib.test(PDFLIB_POPPLER))
{
- GooString* poUserPwd = nullptr;
-
static bool globalParamsCreatedByGDAL = false;
{
CPLMutexHolderD(&hGlobalParamsMutex);
@@ -4310,9 +4308,6 @@ PDFDataset *PDFDataset::Open( GDALOpenInfo * poOpenInfo )
while( true )
{
VSIFSeekL(fp, 0, SEEK_SET);
- if (pszUserPwd)
- poUserPwd = new GooString(pszUserPwd);
-
g_nPopplerErrors = 0;
if( globalParamsCreatedByGDAL )
registerErrorCallback();
@@ -4322,10 +4317,20 @@ PDFDataset *PDFDataset::Open( GDALOpenInfo * poOpenInfo )
oObj.getObj()->initNull();
auto poStream = new VSIPDFFileStream(fp, pszFilename, oObj.getObj());
#endif
+#if POPPLER_MAJOR_VERSION > 22 || (POPPLER_MAJOR_VERSION == 22 && POPPLER_MINOR_VERSION > 2)
+ std::optional<GooString> osUserPwd;
+ if (pszUserPwd)
+ osUserPwd = std::optional<GooString>(pszUserPwd);
+ poDocPoppler = new PDFDoc(poStream, std::optional<GooString>(), osUserPwd);
+#else
+ GooString* poUserPwd = nullptr;
+ if (pszUserPwd)
+ poUserPwd = new GooString(pszUserPwd);
poDocPoppler = new PDFDoc(poStream, nullptr, poUserPwd);
+ delete poUserPwd;
+#endif
if( globalParamsCreatedByGDAL )
registerErrorCallback();
- delete poUserPwd;
if( g_nPopplerErrors >= MAX_POPPLER_ERRORS )
{
PDFFreeDoc(poDocPoppler);

View File

@@ -12,9 +12,8 @@ DESCRIPTION="Translator library for raster geospatial data formats (includes OGR
HOMEPAGE="https://gdal.org/"
SRC_URI="https://download.osgeo.org/${PN}/${PV}/${P}.tar.gz"
# subslot is libgdal.so.<SONAME>
SLOT="0/30"
LICENSE="BSD Info-ZIP MIT"
SLOT="0/30" # subslot is libgdal.so.<SONAME>
KEYWORDS="amd64 ~arm arm64 ~ia64 ppc ppc64 ~riscv x86 ~amd64-linux ~x86-linux ~ppc-macos"
IUSE="armadillo +aux-xml curl cpu_flags_x86_avx cpu_flags_x86_sse cpu_flags_x86_ssse3 debug doc fits geos gif gml hdf5 heif java jpeg jpeg2k lzma mdb mysql netcdf odbc ogdi opencl oracle pdf perl png postgres python spatialite sqlite threads webp xls zstd"
@@ -92,6 +91,7 @@ PATCHES=(
"${FILESDIR}/${PN}-2.3.0-curl.patch" # bug 659840
"${FILESDIR}/${PN}-3.3.0-libdir.patch"
"${FILESDIR}/${P}-poppler-22.01.0-c++17.patch"
"${FILESDIR}/${P}-poppler-22.03.0.patch" # bug 834536
)
src_prepare() {