Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package zathura-plugin-pdf-mupdf for
openSUSE:Factory checked in at 2024-06-18 22:51:49
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/zathura-plugin-pdf-mupdf (Old)
and /work/SRC/openSUSE:Factory/.zathura-plugin-pdf-mupdf.new.19518 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "zathura-plugin-pdf-mupdf"
Tue Jun 18 22:51:49 2024 rev:12 rq:1181424 version:0.4.3
Changes:
--------
---
/work/SRC/openSUSE:Factory/zathura-plugin-pdf-mupdf/zathura-plugin-pdf-mupdf.changes
2024-02-21 17:56:16.735005082 +0100
+++
/work/SRC/openSUSE:Factory/.zathura-plugin-pdf-mupdf.new.19518/zathura-plugin-pdf-mupdf.changes
2024-06-18 22:52:39.284135802 +0200
@@ -1,0 +2,13 @@
+Thu Jun 13 05:55:16 UTC 2024 - Joshua Smith <[email protected]>
+
+- Update patches to current version:
+ * 0001-Don-t-link-against-gumbo.patch
+ * 0002-Revert-Rework-detection-of-mupdf.patch
+- Update to 0.4.3:
+ * Fix crash due to multi-threading issues
+ * Various fixes and improvements
+- Updates from 0.4.2:
+ * Compatible with mupdf 1.24
+ * Various fixes and improvements
+
+-------------------------------------------------------------------
Old:
----
zathura-pdf-mupdf-0.4.1.tar.xz
New:
----
zathura-pdf-mupdf-0.4.3.tar.xz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ zathura-plugin-pdf-mupdf.spec ++++++
--- /var/tmp/diff_new_pack.dtwAva/_old 2024-06-18 22:52:39.840156316 +0200
+++ /var/tmp/diff_new_pack.dtwAva/_new 2024-06-18 22:52:39.840156316 +0200
@@ -1,7 +1,7 @@
#
# spec file for package zathura-plugin-pdf-mupdf
#
-# Copyright (c) 2023 SUSE LLC
+# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -18,7 +18,7 @@
%define realname zathura-pdf-mupdf
Name: zathura-plugin-pdf-mupdf
-Version: 0.4.1
+Version: 0.4.3
Release: 0
Summary: Zathura PDF support through MuPDF
License: Zlib
++++++ 0001-Don-t-link-against-gumbo.patch ++++++
--- /var/tmp/diff_new_pack.dtwAva/_old 2024-06-18 22:52:39.864157201 +0200
+++ /var/tmp/diff_new_pack.dtwAva/_new 2024-06-18 22:52:39.864157201 +0200
@@ -1,17 +1,17 @@
-From 9eabe363db92c006d7542dca38619f2d0d65dd3a Mon Sep 17 00:00:00 2001
-From: llyyr <[email protected]>
-Date: Tue, 7 Mar 2023 06:39:12 +0530
-Subject: [PATCH] Don't link against gumbo
+From d7630c61b492e1d01004c760a8c37861f59386be Mon Sep 17 00:00:00 2001
+From: Josh <[email protected]>
+Date: Thu, 13 Jun 2024 02:06:19 -0400
+Subject: [PATCH 1/2] nogumbo
---
meson.build | 2 --
1 file changed, 2 deletions(-)
diff --git a/meson.build b/meson.build
-index c7b5a8b..1f628af 100644
+index 2d1c6a2..85ccad7 100644
--- a/meson.build
+++ b/meson.build
-@@ -40,7 +40,6 @@ else
+@@ -54,7 +54,6 @@ else
libjpeg = dependency('libjpeg')
libjbig2dec = cc.find_library('jbig2dec')
libopenjp2 = dependency('libopenjp2')
@@ -19,7 +19,7 @@
tesseract = dependency('tesseract')
leptonica = dependency('lept')
mujs = dependency('mujs')
-@@ -49,7 +48,6 @@ else
+@@ -63,7 +62,6 @@ else
libjpeg,
libjbig2dec,
libopenjp2,
@@ -28,6 +28,6 @@
leptonica,
mujs
--
-2.39.2
+2.45.2
++++++ 0002-Revert-Rework-detection-of-mupdf.patch ++++++
--- /var/tmp/diff_new_pack.dtwAva/_old 2024-06-18 22:52:39.876157645 +0200
+++ /var/tmp/diff_new_pack.dtwAva/_new 2024-06-18 22:52:39.880157792 +0200
@@ -1,28 +1,27 @@
-From fe541d1ac43ff4590c371c6f2b5678f355535974 Mon Sep 17 00:00:00 2001
-From: llyyr <[email protected]>
-Date: Tue, 7 Mar 2023 07:13:50 +0530
-Subject: [PATCH] Revert "Rework detection of mupdf"
+From 30cce0de02460c8cb547b5fb5089f68bfc68aab5 Mon Sep 17 00:00:00 2001
+From: Josh <[email protected]>
+Date: Thu, 13 Jun 2024 02:07:06 -0400
+Subject: [PATCH 2/2] mupdf-detection
-This reverts commit 49a85efb915bfed933d251f6074b807d0e1ef385.
---
- meson.build | 17 +++++------------
+ meson.build | 28 +++++-----------------------
meson_options.txt | 6 ++++++
- 2 files changed, 11 insertions(+), 12 deletions(-)
+ 2 files changed, 11 insertions(+), 23 deletions(-)
diff --git a/meson.build b/meson.build
-index 1f628af..e35f679 100644
+index 85ccad7..9d30041 100644
--- a/meson.build
+++ b/meson.build
-@@ -19,7 +19,7 @@ zathura = dependency('zathura', version: '>=0.5.2')
+@@ -22,7 +22,7 @@ zathura = dependency('zathura', version: '>=0.5.2')
girara = dependency('girara-gtk3')
glib = dependency('glib-2.0')
cairo = dependency('cairo')
--mupdf = dependency('mupdf', required: false)
+-mupdf = dependency('mupdf', required: false, version:
'>=@0@.@1@'.format(mupdf_required_version_major, mupdf_required_version_minor))
+mupdf = cc.find_library('mupdf')
mupdfthird = cc.find_library('mupdf-third')
build_dependencies = [
-@@ -27,30 +27,23 @@ build_dependencies = [
+@@ -30,41 +30,23 @@ build_dependencies = [
girara,
glib,
cairo,
@@ -32,7 +31,18 @@
-if not mupdf.found()
- # normal build of mupdf
-- mupdf = cc.find_library('mupdf')
+- mupdf = cc.find_library('mupdf', has_headers: ['mupdf/fitz/version.h',
'mupdf/fitz.h', 'mupdf/pdf.h'], required: true)
+- version_check = '''
+-#include <mupdf/fitz/version.h>
+-
+-#if FZ_VERSION_MAJOR < @0@ || (FZ_VERSION_MAJOR == @0@ && FZ_VERSION_MINOR <
@1@)
+-#error "mupdf @0@.@1@ or newer is requried"
+-#endif
+-'''.format(mupdf_required_version_major, mupdf_required_version_minor)
+- if not cc.compiles(version_check, dependencies: [mupdf])
+- error('mupdf @0@.@1@ or newer is
required'.format(mupdf_required_version_major, mupdf_required_version_minor))
+- endif
+-
- build_dependencies += [mupdf, mupdfthird]
-else
- # build from Debian's libmupdf-dev
@@ -72,6 +82,6 @@
type: 'string',
value: '',
--
-2.39.2
+2.45.2
++++++ zathura-pdf-mupdf-0.4.1.tar.xz -> zathura-pdf-mupdf-0.4.3.tar.xz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/zathura-pdf-mupdf-0.4.1/.clang-format
new/zathura-pdf-mupdf-0.4.3/.clang-format
--- old/zathura-pdf-mupdf-0.4.1/.clang-format 1970-01-01 01:00:00.000000000
+0100
+++ new/zathura-pdf-mupdf-0.4.3/.clang-format 2024-06-04 21:32:44.000000000
+0200
@@ -0,0 +1,15 @@
+---
+Language: Cpp
+BasedOnStyle: LLVM
+AlignConsecutiveAssignments: true
+AllowShortFunctionsOnASingleLine: Empty
+AllowShortIfStatementsOnASingleLine: false
+AlwaysBreakTemplateDeclarations: true
+BreakBeforeBraces: Attach
+ConstructorInitializerIndentWidth: 2
+NamespaceIndentation: All
+PointerAlignment: Left
+TabWidth: 2
+ColumnLimit: 120
+SortIncludes: false
+...
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/zathura-pdf-mupdf-0.4.1/README.md
new/zathura-pdf-mupdf-0.4.3/README.md
--- old/zathura-pdf-mupdf-0.4.1/README.md 2023-09-14 00:15:05.000000000
+0200
+++ new/zathura-pdf-mupdf-0.4.3/README.md 2024-06-04 21:32:44.000000000
+0200
@@ -12,11 +12,11 @@
* `zathura` (>= 0.2.0)
* `girara`
-* `mupdf` (>= 1.20.0)
+* `mupdf` (>= 1.24.0)
For building plugin, the following dependencies are also required:
-* `meson` (>= 0.56)
+* `meson` (>= 0.61)
Installation
------------
@@ -34,4 +34,4 @@
Bugs
----
-Please report bugs at http://git.pwmt.org/pwmt/zathura-pdf-mupdf.
+Please report bugs at https://github.com/pwmt/zathura-pdf-mupdf.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/zathura-pdf-mupdf-0.4.1/meson.build
new/zathura-pdf-mupdf-0.4.3/meson.build
--- old/zathura-pdf-mupdf-0.4.1/meson.build 2023-09-14 00:15:05.000000000
+0200
+++ new/zathura-pdf-mupdf-0.4.3/meson.build 2024-06-04 21:32:44.000000000
+0200
@@ -1,7 +1,7 @@
project('zathura-pdf-mupdf', 'c',
- version: '0.4.1',
- meson_version: '>=0.56',
- default_options: ['c_std=c11', 'warning_level=3']
+ version: '0.4.3',
+ meson_version: '>=0.61',
+ default_options: ['c_std=c17', 'warning_level=3']
)
version = meson.project_version()
@@ -15,11 +15,14 @@
desktopdir = join_paths(datadir, 'applications')
# required dependencies
+mupdf_required_version_major = 1
+mupdf_required_version_minor = 24
+
zathura = dependency('zathura', version: '>=0.5.2')
girara = dependency('girara-gtk3')
glib = dependency('glib-2.0')
cairo = dependency('cairo')
-mupdf = dependency('mupdf', required: false)
+mupdf = dependency('mupdf', required: false, version:
'>=@0@.@1@'.format(mupdf_required_version_major, mupdf_required_version_minor))
mupdfthird = cc.find_library('mupdf-third')
build_dependencies = [
@@ -31,7 +34,18 @@
if not mupdf.found()
# normal build of mupdf
- mupdf = cc.find_library('mupdf')
+ mupdf = cc.find_library('mupdf', has_headers: ['mupdf/fitz/version.h',
'mupdf/fitz.h', 'mupdf/pdf.h'], required: true)
+ version_check = '''
+#include <mupdf/fitz/version.h>
+
+#if FZ_VERSION_MAJOR < @0@ || (FZ_VERSION_MAJOR == @0@ && FZ_VERSION_MINOR <
@1@)
+#error "mupdf @0@.@1@ or newer is requried"
+#endif
+'''.format(mupdf_required_version_major, mupdf_required_version_minor)
+ if not cc.compiles(version_check, dependencies: [mupdf])
+ error('mupdf @0@.@1@ or newer is
required'.format(mupdf_required_version_major, mupdf_required_version_minor))
+ endif
+
build_dependencies += [mupdf, mupdfthird]
else
# build from Debian's libmupdf-dev
@@ -74,7 +88,6 @@
flags = [
'-Werror=implicit-function-declaration',
'-Werror=vla',
- '-fvisibility=hidden'
]
flags = cc.get_supported_arguments(flags)
@@ -96,7 +109,8 @@
dependencies: build_dependencies,
c_args: defines + flags,
install: true,
- install_dir: plugindir
+ install_dir: plugindir,
+ gnu_symbol_visibility: 'hidden'
)
subdir('data')
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/zathura-pdf-mupdf-0.4.1/zathura-pdf-mupdf/document.c
new/zathura-pdf-mupdf-0.4.3/zathura-pdf-mupdf/document.c
--- old/zathura-pdf-mupdf-0.4.1/zathura-pdf-mupdf/document.c 2023-09-14
00:15:05.000000000 +0200
+++ new/zathura-pdf-mupdf-0.4.3/zathura-pdf-mupdf/document.c 2024-06-04
21:32:44.000000000 +0200
@@ -7,11 +7,9 @@
#include "plugin.h"
-#define LENGTH(x) (sizeof(x)/sizeof((x)[0]))
+#define LENGTH(x) (sizeof(x) / sizeof((x)[0]))
-zathura_error_t
-pdf_document_open(zathura_document_t* document)
-{
+zathura_error_t pdf_document_open(zathura_document_t* document) {
zathura_error_t error = ZATHURA_ERROR_OK;
if (document == NULL) {
error = ZATHURA_ERROR_INVALID_ARGUMENTS;
@@ -24,6 +22,8 @@
goto error_ret;
}
+ g_mutex_init(&mupdf_document->mutex);
+
mupdf_document->ctx = fz_new_context(NULL, NULL, FZ_STORE_DEFAULT);
if (mupdf_document->ctx == NULL) {
error = ZATHURA_ERROR_UNKNOWN;
@@ -34,12 +34,12 @@
const char* path = zathura_document_get_path(document);
const char* password = zathura_document_get_password(document);
- fz_try(mupdf_document->ctx){
+ fz_try(mupdf_document->ctx) {
fz_register_document_handlers(mupdf_document->ctx);
mupdf_document->document = fz_open_document(mupdf_document->ctx, path);
}
- fz_catch(mupdf_document->ctx){
+ fz_catch(mupdf_document->ctx) {
error = ZATHURA_ERROR_UNKNOWN;
return error;
}
@@ -65,6 +65,7 @@
error_free:
if (mupdf_document != NULL) {
+ g_mutex_clear(&mupdf_document->mutex);
if (mupdf_document->document != NULL) {
fz_drop_document(mupdf_document->ctx, mupdf_document->document);
}
@@ -82,44 +83,48 @@
return error;
}
-zathura_error_t
-pdf_document_free(zathura_document_t* document, void* data)
-{
+zathura_error_t pdf_document_free(zathura_document_t* document, void* data) {
mupdf_document_t* mupdf_document = data;
if (document == NULL || mupdf_document == NULL) {
return ZATHURA_ERROR_INVALID_ARGUMENTS;
}
+ g_mutex_lock(&mupdf_document->mutex);
+
fz_drop_document(mupdf_document->ctx, mupdf_document->document);
fz_drop_context(mupdf_document->ctx);
+
+ g_mutex_unlock(&mupdf_document->mutex);
+ g_mutex_clear(&mupdf_document->mutex);
+
free(mupdf_document);
zathura_document_set_data(document, NULL);
return ZATHURA_ERROR_OK;
}
-zathura_error_t
-pdf_document_save_as(zathura_document_t* document, void* data, const char*
path)
-{
+zathura_error_t pdf_document_save_as(zathura_document_t* document, void* data,
const char* path) {
mupdf_document_t* mupdf_document = data;
if (document == NULL || mupdf_document == NULL || path == NULL) {
return ZATHURA_ERROR_INVALID_ARGUMENTS;
}
- fz_try (mupdf_document->ctx) {
- pdf_save_document(mupdf_document->ctx, (pdf_document*)
mupdf_document->document, path, NULL);
- } fz_catch (mupdf_document->ctx) {
+ g_mutex_lock(&mupdf_document->mutex);
+ fz_try(mupdf_document->ctx) {
+ pdf_save_document(mupdf_document->ctx,
(pdf_document*)mupdf_document->document, path, NULL);
+ }
+ fz_catch(mupdf_document->ctx) {
+ g_mutex_unlock(&mupdf_document->mutex);
return ZATHURA_ERROR_UNKNOWN;
}
+ g_mutex_unlock(&mupdf_document->mutex);
return ZATHURA_ERROR_OK;
}
-girara_list_t*
-pdf_document_get_information(zathura_document_t* document, void* data,
zathura_error_t* error)
-{
+girara_list_t* pdf_document_get_information(zathura_document_t* document,
void* data, zathura_error_t* error) {
mupdf_document_t* mupdf_document = data;
if (document == NULL || mupdf_document == NULL || error == NULL) {
@@ -136,8 +141,16 @@
return NULL;
}
- fz_try (mupdf_document->ctx) {
- pdf_obj* trailer = pdf_trailer(mupdf_document->ctx, (pdf_document*)
mupdf_document->document);
+ g_mutex_lock(&mupdf_document->mutex);
+ fz_try(mupdf_document->ctx) {
+ pdf_document* pdf_document = pdf_specifics(mupdf_document->ctx,
mupdf_document->document);
+ if (pdf_document == NULL) {
+ girara_list_free(list);
+ list = NULL;
+ break;
+ }
+
+ pdf_obj* trailer = pdf_trailer(mupdf_document->ctx, pdf_document);
pdf_obj* info_dict = pdf_dict_get(mupdf_document->ctx, trailer,
PDF_NAME(Info));
/* get string values */
@@ -147,12 +160,9 @@
} info_value_t;
static const info_value_t string_values[] = {
- { "Title", ZATHURA_DOCUMENT_INFORMATION_TITLE },
- { "Author", ZATHURA_DOCUMENT_INFORMATION_AUTHOR },
- { "Subject", ZATHURA_DOCUMENT_INFORMATION_SUBJECT },
- { "Keywords", ZATHURA_DOCUMENT_INFORMATION_KEYWORDS },
- { "Creator", ZATHURA_DOCUMENT_INFORMATION_CREATOR },
- { "Producer", ZATHURA_DOCUMENT_INFORMATION_PRODUCER }
+ {"Title", ZATHURA_DOCUMENT_INFORMATION_TITLE}, {"Author",
ZATHURA_DOCUMENT_INFORMATION_AUTHOR},
+ {"Subject", ZATHURA_DOCUMENT_INFORMATION_SUBJECT}, {"Keywords",
ZATHURA_DOCUMENT_INFORMATION_KEYWORDS},
+ {"Creator", ZATHURA_DOCUMENT_INFORMATION_CREATOR}, {"Producer",
ZATHURA_DOCUMENT_INFORMATION_PRODUCER},
};
for (unsigned int i = 0; i < LENGTH(string_values); i++) {
@@ -167,19 +177,16 @@
}
zathura_document_information_entry_t* entry =
- zathura_document_information_entry_new(
- string_values[i].type,
- str_value
- );
+ zathura_document_information_entry_new(string_values[i].type,
str_value);
- if (entry != NULL) {
- girara_list_append(list, entry);
- }
+ if (entry != NULL) {
+ girara_list_append(list, entry);
+ }
}
static const info_value_t time_values[] = {
- { "CreationDate", ZATHURA_DOCUMENT_INFORMATION_CREATION_DATE },
- { "ModDate", ZATHURA_DOCUMENT_INFORMATION_MODIFICATION_DATE }
+ {"CreationDate", ZATHURA_DOCUMENT_INFORMATION_CREATION_DATE},
+ {"ModDate", ZATHURA_DOCUMENT_INFORMATION_MODIFICATION_DATE},
};
for (unsigned int i = 0; i < LENGTH(time_values); i++) {
@@ -194,21 +201,23 @@
}
zathura_document_information_entry_t* entry =
- zathura_document_information_entry_new(
- time_values[i].type,
- str_value // FIXME: Convert to common format
- );
+ zathura_document_information_entry_new(time_values[i].type,
+ str_value // FIXME: Convert
to common format
+ );
if (entry != NULL) {
girara_list_append(list, entry);
}
}
- } fz_catch (mupdf_document->ctx) {
+ }
+ fz_catch(mupdf_document->ctx) {
if (error != NULL) {
*error = ZATHURA_ERROR_UNKNOWN;
}
- return NULL;
+ girara_list_free(list);
+ list = NULL;
}
+ g_mutex_unlock(&mupdf_document->mutex);
return list;
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/zathura-pdf-mupdf-0.4.1/zathura-pdf-mupdf/image.c
new/zathura-pdf-mupdf-0.4.3/zathura-pdf-mupdf/image.c
--- old/zathura-pdf-mupdf-0.4.1/zathura-pdf-mupdf/image.c 2023-09-14
00:15:05.000000000 +0200
+++ new/zathura-pdf-mupdf-0.4.3/zathura-pdf-mupdf/image.c 2024-06-04
21:32:44.000000000 +0200
@@ -9,9 +9,7 @@
static void pdf_zathura_image_free(zathura_image_t* image);
-girara_list_t*
-pdf_page_images_get(zathura_page_t* page, void* data, zathura_error_t* error)
-{
+girara_list_t* pdf_page_images_get(zathura_page_t* page, void* data,
zathura_error_t* error) {
mupdf_page_t* mupdf_page = data;
if (page == NULL) {
@@ -21,7 +19,7 @@
goto error_ret;
}
- girara_list_t* list = NULL;
+ girara_list_t* list = NULL;
zathura_document_t* document = zathura_page_get_document(page);
if (document == NULL) {
goto error_ret;
@@ -38,9 +36,10 @@
goto error_free;
}
- girara_list_set_free_function(list, (girara_free_function_t)
pdf_zathura_image_free);
+ girara_list_set_free_function(list,
(girara_free_function_t)pdf_zathura_image_free);
/* Extract images */
+ g_mutex_lock(&mupdf_document->mutex);
mupdf_page_extract_text(mupdf_document, mupdf_page);
fz_stext_block* block;
@@ -57,6 +56,7 @@
girara_list_append(list, zathura_image);
}
}
+ g_mutex_unlock(&mupdf_document->mutex);
return list;
@@ -75,10 +75,8 @@
return NULL;
}
-cairo_surface_t*
-pdf_page_image_get_cairo(zathura_page_t* page, void* data,
- zathura_image_t* image, zathura_error_t* error)
-{
+cairo_surface_t* pdf_page_image_get_cairo(zathura_page_t* page, void* data,
zathura_image_t* image,
+ zathura_error_t* error) {
mupdf_page_t* mupdf_page = data;
if (page == NULL || mupdf_page == NULL || image == NULL || image->data ==
NULL) {
@@ -88,11 +86,20 @@
goto error_ret;
}
- fz_image* mupdf_image = (fz_image*) image->data;
+ zathura_document_t* document = zathura_page_get_document(page);
+ if (document == NULL) {
+ if (error != NULL) {
+ *error = ZATHURA_ERROR_INVALID_ARGUMENTS;
+ }
+ }
+ mupdf_document_t* mupdf_document = zathura_document_get_data(document);
+
+ fz_image* mupdf_image = image->data;
- fz_pixmap* pixmap = NULL;
+ fz_pixmap* pixmap = NULL;
cairo_surface_t* surface = NULL;
+ g_mutex_lock(&mupdf_document->mutex);
pixmap = fz_get_pixmap_from_image(mupdf_page->ctx, mupdf_image, NULL, NULL,
0, 0);
if (pixmap == NULL) {
goto error_free;
@@ -104,7 +111,7 @@
}
unsigned char* surface_data = cairo_image_surface_get_data(surface);
- int rowstride = cairo_image_surface_get_stride(surface);
+ int rowstride = cairo_image_surface_get_stride(surface);
unsigned char* s = fz_pixmap_samples(mupdf_page->ctx, pixmap);
unsigned int n = fz_pixmap_components(mupdf_page->ctx, pixmap);
@@ -120,7 +127,7 @@
p[0] = s[2];
p[1] = s[1];
p[2] = s[0];
- // Gray-scale or mask
+ // Gray-scale or mask
} else {
p[0] = s[0];
p[1] = s[0];
@@ -131,10 +138,12 @@
}
fz_drop_pixmap(mupdf_page->ctx, pixmap);
+ g_mutex_unlock(&mupdf_document->mutex);
return surface;
error_free:
+ g_mutex_unlock(&mupdf_document->mutex);
if (pixmap != NULL) {
fz_drop_pixmap(mupdf_page->ctx, pixmap);
@@ -149,9 +158,7 @@
return NULL;
}
-static void
-pdf_zathura_image_free(zathura_image_t* image)
-{
+static void pdf_zathura_image_free(zathura_image_t* image) {
if (image == NULL) {
return;
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/zathura-pdf-mupdf-0.4.1/zathura-pdf-mupdf/index.c
new/zathura-pdf-mupdf-0.4.3/zathura-pdf-mupdf/index.c
--- old/zathura-pdf-mupdf-0.4.1/zathura-pdf-mupdf/index.c 2023-09-14
00:15:05.000000000 +0200
+++ new/zathura-pdf-mupdf-0.4.3/zathura-pdf-mupdf/index.c 2024-06-04
21:32:44.000000000 +0200
@@ -5,24 +5,23 @@
#include "math.h"
#include "plugin.h"
-static void build_index(fz_context* ctx, fz_document* document, fz_outline*
- outline, girara_tree_node_t* root);
+static void build_index(fz_context* ctx, fz_document* document, fz_outline*
outline, girara_tree_node_t* root);
-girara_tree_node_t*
-pdf_document_index_generate(zathura_document_t* document, void* data,
zathura_error_t* error)
-{
- mupdf_document_t* mupdf_document = data;
-
- if (document == NULL || mupdf_document == NULL) {
+girara_tree_node_t* pdf_document_index_generate(zathura_document_t* document,
void* data, zathura_error_t* error) {
+ if (document == NULL || data == NULL) {
if (error != NULL) {
*error = ZATHURA_ERROR_INVALID_ARGUMENTS;
}
return NULL;
}
+ mupdf_document_t* mupdf_document = data;
+ g_mutex_lock(&mupdf_document->mutex);
+
/* get outline */
fz_outline* outline = fz_load_outline(mupdf_document->ctx,
mupdf_document->document);
if (outline == NULL) {
+ g_mutex_unlock(&mupdf_document->mutex);
if (error != NULL) {
*error = ZATHURA_ERROR_UNKNOWN;
}
@@ -36,21 +35,20 @@
/* free outline */
fz_drop_outline(mupdf_document->ctx, outline);
+ g_mutex_unlock(&mupdf_document->mutex);
return root;
}
-static void
-build_index(fz_context* ctx, fz_document* document, fz_outline* outline,
girara_tree_node_t* root)
-{
+static void build_index(fz_context* ctx, fz_document* document, fz_outline*
outline, girara_tree_node_t* root) {
if (outline == NULL || root == NULL) {
return;
}
while (outline != NULL) {
zathura_index_element_t* index_element =
zathura_index_element_new(outline->title);
- zathura_link_target_t target = {
ZATHURA_LINK_DESTINATION_UNKNOWN, NULL, 0, -1, -1, -1, -1, 0 };
+ zathura_link_target_t target =
{ZATHURA_LINK_DESTINATION_UNKNOWN, NULL, 0, -1, -1, -1, -1, 0};
zathura_link_type_t type = ZATHURA_LINK_INVALID;
- zathura_rectangle_t rect = { .x1 = 0, .y1 = 0, .x2 = 0, .y2
= 0 };
+ zathura_rectangle_t rect = {.x1 = 0, .y1 = 0, .x2 = 0, .y2 =
0};
if (outline->uri == NULL) {
type = ZATHURA_LINK_NONE;
@@ -70,10 +68,14 @@
type = ZATHURA_LINK_GOTO_DEST;
target.destination_type = ZATHURA_LINK_DESTINATION_XYZ;
- target.page_number = fz_page_number_from_location (ctx, document,
location);
- if (!isnan(x)) target.left = x;
- if (!isnan(y)) target.top = y;
- target.zoom = 0.0;
+ target.page_number = fz_page_number_from_location(ctx, document,
location);
+ if (!isnan(x)) {
+ target.left = x;
+ }
+ if (!isnan(y)) {
+ target.top = y;
+ }
+ target.zoom = 0.0;
}
index_element->link = zathura_link_new(type, rect, target);
@@ -91,4 +93,3 @@
outline = outline->next;
}
}
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/zathura-pdf-mupdf-0.4.1/zathura-pdf-mupdf/links.c
new/zathura-pdf-mupdf-0.4.3/zathura-pdf-mupdf/links.c
--- old/zathura-pdf-mupdf-0.4.1/zathura-pdf-mupdf/links.c 2023-09-14
00:15:05.000000000 +0200
+++ new/zathura-pdf-mupdf-0.4.3/zathura-pdf-mupdf/links.c 2024-06-04
21:32:44.000000000 +0200
@@ -5,9 +5,7 @@
#include "plugin.h"
#include "math.h"
-girara_list_t*
-pdf_page_links_get(zathura_page_t* page, void* data, zathura_error_t* error)
-{
+girara_list_t* pdf_page_links_get(zathura_page_t* page, void* data,
zathura_error_t* error) {
if (page == NULL) {
if (error != NULL) {
*error = ZATHURA_ERROR_INVALID_ARGUMENTS;
@@ -15,15 +13,16 @@
goto error_ret;
}
- mupdf_page_t* mupdf_page = data;
+ mupdf_page_t* mupdf_page = data;
zathura_document_t* document = zathura_page_get_document(page);
if (document == NULL || mupdf_page == NULL || mupdf_page->page == NULL) {
goto error_ret;
}
- mupdf_document_t* mupdf_document = zathura_document_get_data(document);;
+ mupdf_document_t* mupdf_document = zathura_document_get_data(document);
+ ;
- girara_list_t* list = girara_list_new2((girara_free_function_t)
zathura_link_free);
+ girara_list_t* list =
girara_list_new2((girara_free_function_t)zathura_link_free);
if (list == NULL) {
if (error != NULL) {
*error = ZATHURA_ERROR_OUT_OF_MEMORY;
@@ -31,6 +30,8 @@
goto error_free;
}
+ g_mutex_lock(&mupdf_document->mutex);
+
fz_link* link = fz_load_links(mupdf_document->ctx, mupdf_page->page);
for (; link != NULL; link = link->next) {
/* extract position */
@@ -41,7 +42,7 @@
position.y2 = link->rect.y1;
zathura_link_type_t type = ZATHURA_LINK_INVALID;
- zathura_link_target_t target = { 0 };
+ zathura_link_target_t target = {ZATHURA_LINK_DESTINATION_UNKNOWN, NULL, 0,
-1, -1, -1, -1, 0};
if (fz_is_external_link(mupdf_document->ctx, link->uri) == 1) {
if (strstr(link->uri, "file://") == link->uri) {
@@ -59,10 +60,14 @@
type = ZATHURA_LINK_GOTO_DEST;
target.destination_type = ZATHURA_LINK_DESTINATION_XYZ;
- target.page_number = fz_page_number_from_location
(mupdf_document->ctx, mupdf_document->document, location);
- if (!isnan(x)) target.left = x;
- if (!isnan(y)) target.top = y;
- target.zoom = 0.0;
+ target.page_number =
fz_page_number_from_location(mupdf_document->ctx, mupdf_document->document,
location);
+ if (!isnan(x)) {
+ target.left = x;
+ }
+ if (!isnan(y)) {
+ target.top = y;
+ }
+ target.zoom = 0.0;
}
zathura_link_t* zathura_link = zathura_link_new(type, position, target);
@@ -70,6 +75,7 @@
girara_list_append(list, zathura_link);
}
}
+ g_mutex_unlock(&mupdf_document->mutex);
return list;
@@ -83,4 +89,3 @@
return NULL;
}
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/zathura-pdf-mupdf-0.4.1/zathura-pdf-mupdf/page.c
new/zathura-pdf-mupdf-0.4.3/zathura-pdf-mupdf/page.c
--- old/zathura-pdf-mupdf-0.4.1/zathura-pdf-mupdf/page.c 2023-09-14
00:15:05.000000000 +0200
+++ new/zathura-pdf-mupdf-0.4.3/zathura-pdf-mupdf/page.c 2024-06-04
21:32:44.000000000 +0200
@@ -2,9 +2,7 @@
#include "plugin.h"
-zathura_error_t
-pdf_page_init(zathura_page_t* page)
-{
+zathura_error_t pdf_page_init(zathura_page_t* page) {
if (page == NULL) {
return ZATHURA_ERROR_INVALID_ARGUMENTS;
}
@@ -15,22 +13,24 @@
unsigned int index = zathura_page_get_index(page);
if (mupdf_page == NULL) {
- return ZATHURA_ERROR_OUT_OF_MEMORY;
+ return ZATHURA_ERROR_OUT_OF_MEMORY;
}
+ g_mutex_lock(&mupdf_document->mutex);
mupdf_page->ctx = mupdf_document->ctx;
if (mupdf_page->ctx == NULL) {
goto error_free;
}
/* load page */
- fz_try (mupdf_page->ctx) {
+ fz_try(mupdf_page->ctx) {
mupdf_page->page = fz_load_page(mupdf_document->ctx,
mupdf_document->document, index);
- } fz_catch (mupdf_page->ctx) {
+ }
+ fz_catch(mupdf_page->ctx) {
goto error_free;
}
- mupdf_page->bbox = fz_bound_page(mupdf_document->ctx, (fz_page*)
mupdf_page->page);
+ mupdf_page->bbox = fz_bound_page(mupdf_document->ctx,
(fz_page*)mupdf_page->page);
/* setup text */
mupdf_page->extracted_text = false;
@@ -39,25 +39,25 @@
if (mupdf_page->text == NULL) {
goto error_free;
}
+ g_mutex_unlock(&mupdf_document->mutex);
zathura_page_set_data(page, mupdf_page);
/* get page dimensions */
- zathura_page_set_width(page, mupdf_page->bbox.x1 - mupdf_page->bbox.x0);
+ zathura_page_set_width(page, mupdf_page->bbox.x1 - mupdf_page->bbox.x0);
zathura_page_set_height(page, mupdf_page->bbox.y1 - mupdf_page->bbox.y0);
return ZATHURA_ERROR_OK;
error_free:
+ g_mutex_unlock(&mupdf_document->mutex);
pdf_page_clear(page, mupdf_page);
return ZATHURA_ERROR_UNKNOWN;
}
-zathura_error_t
-pdf_page_clear(zathura_page_t* page, void* data)
-{
+zathura_error_t pdf_page_clear(zathura_page_t* page, void* data) {
if (page == NULL) {
return ZATHURA_ERROR_INVALID_ARGUMENTS;
}
@@ -66,6 +66,7 @@
zathura_document_t* document = zathura_page_get_document(page);
mupdf_document_t* mupdf_document = zathura_document_get_data(document);
+ g_mutex_lock(&mupdf_document->mutex);
if (mupdf_page != NULL) {
if (mupdf_page->text != NULL) {
fz_drop_stext_page(mupdf_page->ctx, mupdf_page->text);
@@ -77,7 +78,41 @@
free(mupdf_page);
}
+ g_mutex_unlock(&mupdf_document->mutex);
return ZATHURA_ERROR_UNKNOWN;
}
+zathura_error_t pdf_page_get_label(zathura_page_t* page, void* data, char**
label) {
+ if (page == NULL || data == NULL || label == NULL) {
+ return ZATHURA_ERROR_INVALID_ARGUMENTS;
+ }
+
+ mupdf_page_t* mupdf_page = data;
+ zathura_document_t* document = zathura_page_get_document(page);
+ if (document == NULL) {
+ return ZATHURA_ERROR_INVALID_ARGUMENTS;
+ }
+ mupdf_document_t* mupdf_document = zathura_document_get_data(document);
+
+ char buf[16];
+
+ g_mutex_lock(&mupdf_document->mutex);
+ fz_try(mupdf_page->ctx) {
+ fz_page_label(mupdf_page->ctx, mupdf_page->page, buf, sizeof(buf));
+ }
+ fz_catch(mupdf_page->ctx) {
+ g_mutex_unlock(&mupdf_document->mutex);
+ return ZATHURA_ERROR_UNKNOWN;
+ }
+ g_mutex_unlock(&mupdf_document->mutex);
+
+ // fz_page_label() may return an empty string if the label is undefined.
+ if (buf[0] != '\0') {
+ *label = g_strdup(buf);
+ } else {
+ *label = NULL;
+ }
+
+ return ZATHURA_ERROR_OK;
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/zathura-pdf-mupdf-0.4.1/zathura-pdf-mupdf/plugin.c
new/zathura-pdf-mupdf-0.4.3/zathura-pdf-mupdf/plugin.c
--- old/zathura-pdf-mupdf-0.4.1/zathura-pdf-mupdf/plugin.c 2023-09-14
00:15:05.000000000 +0200
+++ new/zathura-pdf-mupdf-0.4.3/zathura-pdf-mupdf/plugin.c 2024-06-04
21:32:44.000000000 +0200
@@ -2,31 +2,29 @@
#include "plugin.h"
-ZATHURA_PLUGIN_REGISTER_WITH_FUNCTIONS(
- "pdf-mupdf",
- VERSION_MAJOR, VERSION_MINOR, VERSION_REV,
- ZATHURA_PLUGIN_FUNCTIONS({
- .document_open = pdf_document_open,
- .document_free = pdf_document_free,
- .document_save_as = pdf_document_save_as,
- .document_index_generate = pdf_document_index_generate,
- .document_get_information = pdf_document_get_information,
- .page_init = pdf_page_init,
- .page_clear = pdf_page_clear,
- .page_search_text = pdf_page_search_text,
- .page_links_get = pdf_page_links_get,
- .page_images_get = pdf_page_images_get,
- .page_get_text = pdf_page_get_text,
- .page_get_selection = pdf_page_get_selection,
- .page_render = pdf_page_render,
- .page_render_cairo = pdf_page_render_cairo,
- .page_image_get_cairo = pdf_page_image_get_cairo
- }),
- ZATHURA_PLUGIN_MIMETYPES({
- "application/pdf",
- "application/oxps",
- "application/epub+zip",
- "application/x-fictionbook",
- "text/xml"
- })
-)
+ZATHURA_PLUGIN_REGISTER_WITH_FUNCTIONS("pdf-mupdf", VERSION_MAJOR,
VERSION_MINOR, VERSION_REV,
+ ZATHURA_PLUGIN_FUNCTIONS({
+ .document_open =
pdf_document_open,
+ .document_free =
pdf_document_free,
+ .document_save_as =
pdf_document_save_as,
+ .document_index_generate =
pdf_document_index_generate,
+ .document_get_information =
pdf_document_get_information,
+ .page_init =
pdf_page_init,
+ .page_clear =
pdf_page_clear,
+ .page_search_text =
pdf_page_search_text,
+ .page_links_get =
pdf_page_links_get,
+ .page_images_get =
pdf_page_images_get,
+ .page_get_text =
pdf_page_get_text,
+ .page_get_selection =
pdf_page_get_selection,
+ .page_render =
pdf_page_render,
+ .page_render_cairo =
pdf_page_render_cairo,
+ .page_image_get_cairo =
pdf_page_image_get_cairo,
+ .page_get_label =
pdf_page_get_label,
+ }),
+ ZATHURA_PLUGIN_MIMETYPES({
+ "application/pdf",
+ "application/oxps",
+ "application/epub+zip",
+ "application/x-fictionbook",
+ "text/xml",
+ }))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/zathura-pdf-mupdf-0.4.1/zathura-pdf-mupdf/plugin.h
new/zathura-pdf-mupdf-0.4.3/zathura-pdf-mupdf/plugin.h
--- old/zathura-pdf-mupdf-0.4.1/zathura-pdf-mupdf/plugin.h 2023-09-14
00:15:05.000000000 +0200
+++ new/zathura-pdf-mupdf-0.4.3/zathura-pdf-mupdf/plugin.h 2024-06-04
21:32:44.000000000 +0200
@@ -10,18 +10,17 @@
#include <mupdf/fitz.h>
#include <cairo.h>
-typedef struct mupdf_document_s
-{
- fz_context* ctx; /**< Context */
+typedef struct mupdf_document_s {
+ fz_context* ctx; /**< Context */
fz_document* document; /**< mupdf document */
+ GMutex mutex;
} mupdf_document_t;
-typedef struct mupdf_page_s
-{
- fz_page* page; /**< Reference to the mupdf page */
- fz_context* ctx; /**< Context */
+typedef struct mupdf_page_s {
+ fz_page* page; /**< Reference to the mupdf page */
+ fz_context* ctx; /**< Context */
fz_stext_page* text; /**< Page text */
- fz_rect bbox; /**< Bbox */
+ fz_rect bbox; /**< Bbox */
bool extracted_text; /**< If text has already been extracted */
} mupdf_page_t;
@@ -49,8 +48,7 @@
* @return ZATHURA_ERROR_OK when no error occurred, otherwise see
* zathura_error_t
*/
-zathura_error_t pdf_document_save_as(zathura_document_t* document,
- void* mupdf_document, const char* path);
+zathura_error_t pdf_document_save_as(zathura_document_t* document, void*
mupdf_document, const char* path);
/**
* Generates the index of the document
@@ -61,8 +59,8 @@
* @return Tree node object or NULL if an error occurred (e.g.: the document
has
* no index)
*/
-girara_tree_node_t* pdf_document_index_generate(zathura_document_t* document,
- void* mupdf_document, zathura_error_t* error);
+girara_tree_node_t* pdf_document_index_generate(zathura_document_t* document,
void* mupdf_document,
+ zathura_error_t* error);
/**
* Returns a reference to a page
@@ -120,8 +118,8 @@
* error occurred
* @return The cairo image surface or NULL if an error occurred
*/
-cairo_surface_t* pdf_page_image_get_cairo(zathura_page_t* page, void*
- mupdf_page, zathura_image_t* image, zathura_error_t* error);
+cairo_surface_t* pdf_page_image_get_cairo(zathura_page_t* page, void*
mupdf_page, zathura_image_t* image,
+ zathura_error_t* error);
/**
* Get text for selection
@@ -141,7 +139,8 @@
* occurred
* @return List of rectangles or NULL if an error occurred.
*/
-girara_list_t* pdf_page_get_selection(zathura_page_t* page, void* mupdf_page,
zathura_rectangle_t rectangle, zathura_error_t* error);
+girara_list_t* pdf_page_get_selection(zathura_page_t* page, void* mupdf_page,
zathura_rectangle_t rectangle,
+ zathura_error_t* error);
/**
* Returns a list of document information entries of the document
@@ -151,8 +150,18 @@
* error occurred
* @return List of information entries or NULL if an error occurred
*/
-girara_list_t* pdf_document_get_information(zathura_document_t* document,
- void* mupdf_document, zathura_error_t* error);
+girara_list_t* pdf_document_get_information(zathura_document_t* document,
void* mupdf_document, zathura_error_t* error);
+
+/**
+ * Get the page label
+ *
+ * @param page Page
+ * @param data Mupdf page representation
+ * @param label Label
+ * @return ZATHURA_ERROR_OK when no error occurred, otherwise see
+ * zathura_error_t
+ */
+zathura_error_t pdf_page_get_label(zathura_page_t* page, void* data, char**
label);
/**
* Renders a page and returns a allocated image buffer which has to be freed
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/zathura-pdf-mupdf-0.4.1/zathura-pdf-mupdf/render.c
new/zathura-pdf-mupdf-0.4.3/zathura-pdf-mupdf/render.c
--- old/zathura-pdf-mupdf-0.4.1/zathura-pdf-mupdf/render.c 2023-09-14
00:15:05.000000000 +0200
+++ new/zathura-pdf-mupdf-0.4.3/zathura-pdf-mupdf/render.c 2024-06-04
21:32:44.000000000 +0200
@@ -4,31 +4,30 @@
#include "plugin.h"
-static zathura_error_t
-pdf_page_render_to_buffer(mupdf_document_t* mupdf_document, mupdf_page_t*
mupdf_page,
- unsigned char* image, int GIRARA_UNUSED(rowstride),
int GIRARA_UNUSED(components),
- unsigned int page_width, unsigned int page_height,
- double scalex, double scaley)
-{
- if (mupdf_document == NULL ||
- mupdf_document->ctx == NULL ||
- mupdf_page == NULL ||
- mupdf_page->page == NULL ||
+static zathura_error_t pdf_page_render_to_buffer(mupdf_document_t*
mupdf_document, mupdf_page_t* mupdf_page,
+ unsigned char* image, int
GIRARA_UNUSED(rowstride),
+ int
GIRARA_UNUSED(components), unsigned int page_width,
+ unsigned int page_height,
double scalex, double scaley) {
+ if (mupdf_document == NULL || mupdf_document->ctx == NULL || mupdf_page ==
NULL || mupdf_page->page == NULL ||
image == NULL) {
return ZATHURA_ERROR_UNKNOWN;
}
- fz_irect irect = { .x1 = page_width, .y1 = page_height };
- fz_rect rect = { .x1 = page_width, .y1 = page_height };
+ g_mutex_lock(&mupdf_document->mutex);
+
+ fz_irect irect = {.x1 = page_width, .y1 = page_height};
+ fz_rect rect = {.x1 = page_width, .y1 = page_height};
fz_display_list* display_list = fz_new_display_list(mupdf_page->ctx, rect);
fz_device* device = fz_new_list_device(mupdf_page->ctx,
display_list);
- fz_try (mupdf_document->ctx) {
+ fz_try(mupdf_document->ctx) {
fz_matrix m;
m = fz_scale(scalex, scaley);
fz_run_page(mupdf_document->ctx, mupdf_page->page, device, m, NULL);
- } fz_catch (mupdf_document->ctx) {
+ }
+ fz_catch(mupdf_document->ctx) {
+ g_mutex_unlock(&mupdf_document->mutex);
return ZATHURA_ERROR_UNKNOWN;
}
@@ -48,12 +47,11 @@
fz_drop_pixmap(mupdf_page->ctx, pixmap);
fz_drop_display_list(mupdf_page->ctx, display_list);
+ g_mutex_unlock(&mupdf_document->mutex);
return ZATHURA_ERROR_OK;
}
-zathura_image_buffer_t*
-pdf_page_render(zathura_page_t* page, void* data, zathura_error_t* error)
-{
+zathura_image_buffer_t* pdf_page_render(zathura_page_t* page, void* data,
zathura_error_t* error) {
mupdf_page_t* mupdf_page = data;
if (page == NULL || mupdf_page == NULL) {
@@ -89,8 +87,8 @@
mupdf_document_t* mupdf_document = zathura_document_get_data(document);
- zathura_error_t error_render = pdf_page_render_to_buffer(mupdf_document,
mupdf_page, image, rowstride, 3,
- page_width, page_height,
scalex, scaley);
+ zathura_error_t error_render = pdf_page_render_to_buffer(mupdf_document,
mupdf_page, image, rowstride, 3, page_width,
+ page_height,
scalex, scaley);
if (error_render != ZATHURA_ERROR_OK) {
zathura_image_buffer_free(image_buffer);
@@ -103,9 +101,7 @@
return image_buffer;
}
-zathura_error_t
-pdf_page_render_cairo(zathura_page_t* page, void* data, cairo_t* cairo, bool
GIRARA_UNUSED(printing))
-{
+zathura_error_t pdf_page_render_cairo(zathura_page_t* page, void* data,
cairo_t* cairo, bool GIRARA_UNUSED(printing)) {
mupdf_page_t* mupdf_page = data;
if (page == NULL || mupdf_page == NULL) {
@@ -113,8 +109,7 @@
}
cairo_surface_t* surface = cairo_get_target(cairo);
- if (surface == NULL ||
- cairo_surface_status(surface) != CAIRO_STATUS_SUCCESS ||
+ if (surface == NULL || cairo_surface_status(surface) != CAIRO_STATUS_SUCCESS
||
cairo_surface_get_type(surface) != CAIRO_SURFACE_TYPE_IMAGE) {
return ZATHURA_ERROR_UNKNOWN;
}
@@ -127,15 +122,14 @@
unsigned int page_width = cairo_image_surface_get_width(surface);
unsigned int page_height = cairo_image_surface_get_height(surface);
- double scalex = ((double) page_width) / zathura_page_get_width(page);
- double scaley = ((double) page_height) /zathura_page_get_height(page);
+ double scalex = ((double)page_width) / zathura_page_get_width(page);
+ double scaley = ((double)page_height) / zathura_page_get_height(page);
int rowstride = cairo_image_surface_get_stride(surface);
unsigned char* image = cairo_image_surface_get_data(surface);
mupdf_document_t* mupdf_document = zathura_document_get_data(document);
- return pdf_page_render_to_buffer(mupdf_document, mupdf_page, image,
rowstride, 4,
- page_width, page_height, scalex, scaley);
+ return pdf_page_render_to_buffer(mupdf_document, mupdf_page, image,
rowstride, 4, page_width, page_height, scalex,
+ scaley);
}
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/zathura-pdf-mupdf-0.4.1/zathura-pdf-mupdf/search.c
new/zathura-pdf-mupdf-0.4.3/zathura-pdf-mupdf/search.c
--- old/zathura-pdf-mupdf-0.4.1/zathura-pdf-mupdf/search.c 2023-09-14
00:15:05.000000000 +0200
+++ new/zathura-pdf-mupdf-0.4.3/zathura-pdf-mupdf/search.c 2024-06-04
21:32:44.000000000 +0200
@@ -7,11 +7,7 @@
#include "plugin.h"
#include "utils.h"
-girara_list_t*
-pdf_page_search_text(zathura_page_t* page, void* data, const char* text,
zathura_error_t* error)
-{
- mupdf_page_t* mupdf_page = data;
-
+girara_list_t* pdf_page_search_text(zathura_page_t* page, void* data, const
char* text, zathura_error_t* error) {
if (page == NULL || text == NULL) {
if (error != NULL) {
*error = ZATHURA_ERROR_INVALID_ARGUMENTS;
@@ -19,12 +15,14 @@
goto error_ret;
}
+ mupdf_page_t* mupdf_page = data;
zathura_document_t* document = zathura_page_get_document(page);
if (document == NULL || mupdf_page == NULL || mupdf_page->text == NULL) {
goto error_ret;
}
- mupdf_document_t* mupdf_document = zathura_document_get_data(document);;
+ mupdf_document_t* mupdf_document = zathura_document_get_data(document);
+ ;
girara_list_t* list = girara_list_new2(g_free);
if (list == NULL) {
@@ -34,20 +32,21 @@
goto error_free;
}
+ g_mutex_lock(&mupdf_document->mutex);
+
/* extract text */
if (mupdf_page->extracted_text == false) {
mupdf_page_extract_text(mupdf_document, mupdf_page);
}
fz_quad* hit_bbox = fz_malloc_array(mupdf_page->ctx, N_SEARCH_RESULTS,
fz_quad);
- int num_results = fz_search_stext_page(mupdf_page->ctx, mupdf_page->text,
- text, NULL, hit_bbox, N_SEARCH_RESULTS);
+ int num_results = fz_search_stext_page(mupdf_page->ctx, mupdf_page->text,
text, NULL, hit_bbox, N_SEARCH_RESULTS);
fz_rect r;
for (int i = 0; i < num_results; i++) {
zathura_rectangle_t* rectangle = g_malloc0(sizeof(zathura_rectangle_t));
- r = fz_rect_from_quad(hit_bbox[i]);
+ r = fz_rect_from_quad(hit_bbox[i]);
rectangle->x1 = r.x0;
rectangle->x2 = r.x1;
rectangle->y1 = r.y0;
@@ -57,12 +56,13 @@
}
fz_free(mupdf_page->ctx, hit_bbox);
+ g_mutex_unlock(&mupdf_document->mutex);
return list;
error_free:
- if (list != NULL ) {
+ if (list != NULL) {
girara_list_free(list);
}
@@ -74,4 +74,3 @@
return NULL;
}
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/zathura-pdf-mupdf-0.4.1/zathura-pdf-mupdf/select.c
new/zathura-pdf-mupdf-0.4.3/zathura-pdf-mupdf/select.c
--- old/zathura-pdf-mupdf-0.4.1/zathura-pdf-mupdf/select.c 2023-09-14
00:15:05.000000000 +0200
+++ new/zathura-pdf-mupdf-0.4.3/zathura-pdf-mupdf/select.c 2024-06-04
21:32:44.000000000 +0200
@@ -5,9 +5,7 @@
#include "plugin.h"
#include "utils.h"
-char*
-pdf_page_get_text(zathura_page_t* page, void* data, zathura_rectangle_t
rectangle, zathura_error_t* error)
-{
+char* pdf_page_get_text(zathura_page_t* page, void* data, zathura_rectangle_t
rectangle, zathura_error_t* error) {
mupdf_page_t* mupdf_page = data;
if (page == NULL || mupdf_page == NULL || mupdf_page->text == NULL) {
@@ -19,19 +17,23 @@
zathura_document_t* document = zathura_page_get_document(page);
mupdf_document_t* mupdf_document = zathura_document_get_data(document);
+ g_mutex_lock(&mupdf_document->mutex);
if (mupdf_page->extracted_text == false) {
mupdf_page_extract_text(mupdf_document, mupdf_page);
}
- fz_point a = { rectangle.x1, rectangle.y1 };
- fz_point b = { rectangle.x2, rectangle.y2 };
+ fz_point a = {rectangle.x1, rectangle.y1};
+ fz_point b = {rectangle.x2, rectangle.y2};
+ char* ret = NULL;
#ifdef _WIN32
- return fz_copy_selection(mupdf_page->ctx, mupdf_page->text, a, b, 1);
+ ret = fz_copy_selection(mupdf_page->ctx, mupdf_page->text, a, b, 1);
#else
- return fz_copy_selection(mupdf_page->ctx, mupdf_page->text, a, b, 0);
+ ret = fz_copy_selection(mupdf_page->ctx, mupdf_page->text, a, b, 0);
#endif
+ g_mutex_unlock(&mupdf_document->mutex);
+ return ret;
error_ret:
@@ -42,8 +44,8 @@
return NULL;
}
-girara_list_t*
-pdf_page_get_selection(zathura_page_t* page, void* data, zathura_rectangle_t
rectangle, zathura_error_t* error) {
+girara_list_t* pdf_page_get_selection(zathura_page_t* page, void* data,
zathura_rectangle_t rectangle,
+ zathura_error_t* error) {
mupdf_page_t* mupdf_page = data;
@@ -56,13 +58,14 @@
zathura_document_t* document = zathura_page_get_document(page);
mupdf_document_t* mupdf_document = zathura_document_get_data(document);
+ g_mutex_lock(&mupdf_document->mutex);
if (mupdf_page->extracted_text == false) {
mupdf_page_extract_text(mupdf_document, mupdf_page);
}
- fz_point a = { rectangle.x1, rectangle.y1 };
- fz_point b = { rectangle.x2, rectangle.y2 };
+ fz_point a = {rectangle.x1, rectangle.y1};
+ fz_point b = {rectangle.x2, rectangle.y2};
girara_list_t* list = girara_list_new2(g_free);
if (list == NULL) {
@@ -72,14 +75,14 @@
goto error_free;
}
- fz_quad* hits = fz_malloc_array(mupdf_page->ctx, MAX_QUADS, fz_quad);
+ fz_quad* hits = fz_malloc_array(mupdf_page->ctx, MAX_QUADS, fz_quad);
int num_results = fz_highlight_selection(mupdf_page->ctx, mupdf_page->text,
a, b, hits, MAX_QUADS);
fz_rect r;
for (int i = 0; i < num_results; i++) {
zathura_rectangle_t* inner_rectangle =
g_malloc0(sizeof(zathura_rectangle_t));
- r = fz_rect_from_quad(hits[i]);
+ r = fz_rect_from_quad(hits[i]);
inner_rectangle->x1 = r.x0;
inner_rectangle->x2 = r.x1;
inner_rectangle->y1 = r.y0;
@@ -89,13 +92,15 @@
}
fz_free(mupdf_page->ctx, hits);
+ g_mutex_unlock(&mupdf_document->mutex);
return list;
error_free:
+ g_mutex_unlock(&mupdf_document->mutex);
- if (list != NULL ) {
- girara_list_free(list);
+ if (list != NULL) {
+ girara_list_free(list);
}
error_ret:
@@ -106,4 +111,3 @@
return NULL;
}
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/zathura-pdf-mupdf-0.4.1/zathura-pdf-mupdf/utils.c
new/zathura-pdf-mupdf-0.4.3/zathura-pdf-mupdf/utils.c
--- old/zathura-pdf-mupdf-0.4.1/zathura-pdf-mupdf/utils.c 2023-09-14
00:15:05.000000000 +0200
+++ new/zathura-pdf-mupdf-0.4.3/zathura-pdf-mupdf/utils.c 2024-06-04
21:32:44.000000000 +0200
@@ -2,16 +2,14 @@
#include "utils.h"
-void
-mupdf_page_extract_text(mupdf_document_t* mupdf_document, mupdf_page_t*
mupdf_page) {
- if (mupdf_document == NULL || mupdf_document->ctx == NULL || mupdf_page ==
NULL ||
- mupdf_page->text == NULL) {
+void mupdf_page_extract_text(mupdf_document_t* mupdf_document, mupdf_page_t*
mupdf_page) {
+ if (mupdf_document == NULL || mupdf_document->ctx == NULL || mupdf_page ==
NULL || mupdf_page->text == NULL) {
return;
}
fz_device* volatile text_device = NULL;
- fz_try (mupdf_page->ctx) {
+ fz_try(mupdf_page->ctx) {
text_device = fz_new_stext_device(mupdf_page->ctx, mupdf_page->text, NULL);
/* Disable FZ_DONT_INTERPOLATE_IMAGES to collect image blocks */
@@ -20,11 +18,12 @@
fz_matrix ctm;
ctm = fz_scale(1.0, 1.0);
fz_run_page(mupdf_page->ctx, mupdf_page->page, text_device, ctm, NULL);
- } fz_always (mupdf_document->ctx) {
+ }
+ fz_always(mupdf_document->ctx) {
fz_close_device(mupdf_page->ctx, text_device);
fz_drop_device(mupdf_page->ctx, text_device);
- } fz_catch(mupdf_document->ctx) {
}
+ fz_catch(mupdf_document->ctx) {}
mupdf_page->extracted_text = true;
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/zathura-pdf-mupdf-0.4.1/zathura-pdf-mupdf/utils.h
new/zathura-pdf-mupdf-0.4.3/zathura-pdf-mupdf/utils.h
--- old/zathura-pdf-mupdf-0.4.1/zathura-pdf-mupdf/utils.h 2023-09-14
00:15:05.000000000 +0200
+++ new/zathura-pdf-mupdf-0.4.3/zathura-pdf-mupdf/utils.h 2024-06-04
21:32:44.000000000 +0200
@@ -5,7 +5,6 @@
#include "plugin.h"
-void mupdf_page_extract_text(mupdf_document_t* mupdf_document,
- mupdf_page_t* mupdf_page);
+void mupdf_page_extract_text(mupdf_document_t* mupdf_document, mupdf_page_t*
mupdf_page);
#endif // UTILS_H