diff options
author | 2024-02-05 00:05:08 +0100 | |
---|---|---|
committer | 2024-02-05 00:05:48 +0100 | |
commit | d7930585b2eaf14c6e93263898b0f311ce12969a (patch) | |
tree | 18bc6d48bbd5920fa3e214d98cb9a94d5473346f /app-text/paperwork-backend | |
parent | x11-apps/xmore: Version bump to 1.0.4 (diff) | |
download | gentoo-d7930585b2eaf14c6e93263898b0f311ce12969a.tar.gz gentoo-d7930585b2eaf14c6e93263898b0f311ce12969a.tar.bz2 gentoo-d7930585b2eaf14c6e93263898b0f311ce12969a.zip |
app-text/paperwork-backend: fix PDF file segfault
Backport from upstream workaround
Closes: https://bugs.gentoo.org/765526
Signed-off-by: Bernard Cafarelli <voyageur@gentoo.org>
Diffstat (limited to 'app-text/paperwork-backend')
-rw-r--r-- | app-text/paperwork-backend/files/paperwork-backend-2.2.1-cairo_workaround.patch | 52 | ||||
-rw-r--r-- | app-text/paperwork-backend/paperwork-backend-2.2.1-r1.ebuild | 63 |
2 files changed, 115 insertions, 0 deletions
diff --git a/app-text/paperwork-backend/files/paperwork-backend-2.2.1-cairo_workaround.patch b/app-text/paperwork-backend/files/paperwork-backend-2.2.1-cairo_workaround.patch new file mode 100644 index 000000000000..01eb2a6154b0 --- /dev/null +++ b/app-text/paperwork-backend/files/paperwork-backend-2.2.1-cairo_workaround.patch @@ -0,0 +1,52 @@ +From c9430b844fbcedc9119e3d464f5f0c85feb7b197 Mon Sep 17 00:00:00 2001 +From: Jerome Flesch <jflesch@openpaper.work> +Date: Sun, 4 Feb 2024 20:33:27 +0100 +Subject: [PATCH] Backend/docexport PDF: Workaround Cairo bug that causes + occasional crashes when exporting to generated PDF. + +Closes #942 +--- + .../src/paperwork_backend/docexport/pdf.py | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +diff --git a/paperwork-backend/src/paperwork_backend/docexport/pdf.py b/paperwork-backend/src/paperwork_backend/docexport/pdf.py +index 160e60710..befded73c 100644 +--- a/paperwork-backend/src/paperwork_backend/docexport/pdf.py ++++ b/paperwork-backend/src/paperwork_backend/docexport/pdf.py +@@ -115,6 +115,8 @@ class PdfCreator(object): + ) + self.pdf_context = cairo.Context(self.pdf_surface) + ++ self.gc_protection = [] # WORKAROUND(Jflesch): Cairo crash ++ + def set_page_size(self, img_size): + # portrait or landscape + if (img_size[0] < img_size[1]): +@@ -187,6 +189,16 @@ class PdfCreator(object): + "pillow_to_surface", img, + intermediate="jpeg", quality=int(self.quality * 100) + ) ++ # WORKAROUND(Jflesch): ++ # If Cairo supports JPEG embedding, we use ++ # cairo.ImageSurface.set_mime_data() instead of the usual Cairo ++ # surface functions to draw the image. It seems this function does ++ # not increment the ref counter of the surface object ++ # --> the Python GC tends to collect it while Cairo is still going ++ # to use it to generate the PDF. ++ # --> we have to keep a reference on it ourselves, until the page has ++ # been generated. ++ self.gc_protection.append(img_surface) + + self.pdf_context.save() + try: +@@ -199,6 +211,7 @@ class PdfCreator(object): + + def next_page(self): + self.pdf_context.show_page() ++ self.gc_protection = [] # WORKAROUND(Jflesch): Cairo crash + + def finish(self): + self.pdf_surface.flush() +-- +GitLab + diff --git a/app-text/paperwork-backend/paperwork-backend-2.2.1-r1.ebuild b/app-text/paperwork-backend/paperwork-backend-2.2.1-r1.ebuild new file mode 100644 index 000000000000..bb7a9c75061b --- /dev/null +++ b/app-text/paperwork-backend/paperwork-backend-2.2.1-r1.ebuild @@ -0,0 +1,63 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +DISTUTILS_USE_PEP517=setuptools +PYTHON_COMPAT=( python3_{9..12} ) + +inherit distutils-r1 + +DESCRIPTION="Backend part of Paperwork (Python API, no UI)" +HOMEPAGE="https://gitlab.gnome.org/World/OpenPaperwork" +# Update from release hash at: +# https://gitlab.gnome.org/World/OpenPaperwork/paperwork/-/tags +REL_HASH="0bea4054" +SRC_URI="https://gitlab.gnome.org/World/OpenPaperwork/paperwork/-/archive/${PV}/paperwork-${PV}.tar.bz2 + https://download.openpaper.work/data/paperwork/master_${REL_HASH}/data.tar.gz -> paperwork-data-${PV}.tar.gz" + +LICENSE="GPL-3" +SLOT="0" +KEYWORDS="~amd64 ~x86" + +RDEPEND=" + app-text/openpaperwork-core[${PYTHON_USEDEP}] + app-text/openpaperwork-gtk[${PYTHON_USEDEP}] + app-text/poppler[introspection] + dev-python/distro[${PYTHON_USEDEP}] + dev-python/pillow[${PYTHON_USEDEP}] + dev-python/psutil[${PYTHON_USEDEP}] + dev-python/pycairo[${PYTHON_USEDEP}] + dev-python/pycountry[${PYTHON_USEDEP}] + dev-python/pygobject:3[${PYTHON_USEDEP}] + dev-python/termcolor[${PYTHON_USEDEP}] + dev-python/whoosh[${PYTHON_USEDEP}] + sci-libs/scikit-learn[${PYTHON_USEDEP}] +" +BDEPEND=" + ${RDEPEND} + dev-python/setuptools-scm[${PYTHON_USEDEP}] + sys-apps/which + sys-devel/gettext + test? ( + dev-python/libpillowfight[${PYTHON_USEDEP}] + media-libs/libinsane + ) +" +S=${WORKDIR}/paperwork-${PV}/${PN} + +distutils_enable_tests unittest + +export SETUPTOOLS_SCM_PRETEND_VERSION=${PV} + +src_prepare() { + default + cd "${WORKDIR}"/paperwork-${PV} || die + eapply "${FILESDIR}"/${P}-cairo_workaround.patch +} + +python_compile() { + emake l10n_compile + + distutils-r1_python_compile +} |