app-text/lektra: add 0.8.1, drop 0.8.0-r1

Bump bundled mupdf to 1.28.6, matching the submodule pin of 0.8.1.
Drop the empty-document patch: the fixes are in 0.8.1 upstream.
Disable the new WITH_MICROTEX option; its submodules are not vendored.

Assisted-by: Claude:claude-sonnet-5-5
Signed-off-by: Zakk <zakk@gentoozh.org>
This commit is contained in:
Zakk committed 2026-11-29 19:10:16 +11:00
1 parent b36e23c533
commit 6832e46f5a
3 files changed
+5 -299

No files matched your search

+2 -2
View File
@@ -1,3 +1,3 @@
DIST lektra-0.8.0.tar.gz 43420304 BLAKE2B 917e77aec23ce70696225263112ab558dc69ecc03faf157e199db7a6e2e293a5e850eb5132cce17dc633c332b3afbc227baf44976663f59cae204a34684e2a0e SHA512 78888ea015f0ad2764dd24a8cb2269d17db1aebffdd659cfd31c839f1d6a8adc18f5fb8d40a3202ae399e7e65f9b40d51cefba2b98a0cc37d270059fb9ae28cb
DIST lektra-0.8.1.tar.gz 1302098 BLAKE2B 1e7deb07f3159965f5b83949ffb97b1b2f55eb499dbd6e72d2c02fa7d66c04b65a84f5e5f82ef5bc82052711e33862cc86d34dd5cf354944164587fac6f6a796 SHA512 611214c9b899d63096e8d56c72b63ea0f40c27fde41c5fd334e582b7a6fc4c9cdcf34d2a0b89d85a9eb319471328a3dd9106e3860749426280aefcdc93fcda7b
DIST lektra-synctex-917617707955cde0c2fae127130d9d3129303cbc.tar.gz 7284576 BLAKE2B 9cb093e41ef9416e83157c8fb0f916527b142b383f80614da580bc2271e3cba9205541d3a1e02363980a3daa5a3d49c6ec2bd72ad734b2e6b2a8ace1d1ef5e4b SHA512 a25762151f8906b56ef219e36a75ad96d8deebbcd50d8cbc394dd43b4d9d63f7a91ae94443da5ba241b4378681ecd13934c4751c26b8f6d9cb9545ff19ba88c7
DIST mupdf-1.28.5-source.tar.gz 68919385 BLAKE2B a2ff55fe8acac67e025cd873344cf6573247da40bc2bf20dd6d5d6d25a99d31f604a4ec64438d8e05a3e6339f3b885b68f735a4fcf7ab08e63a1e12edf071e11 SHA512 a23e03cec246bb15aae904db210268d4f1a88799ae321c9a59fdd855bc8cada4aee9bbc4aa405e7584fa08a02aae4ec25c310c9090bdc1ecce92c8ef4e1d5a2e
DIST mupdf-1.28.6-source.tar.gz 68924915 BLAKE2B a43d20b9d8b100f189c47d447569201f65104aa10d37c6629cebb739a226d2ec95aa32a8268e7672c05d8bef959aaa323892fd5824e919e4967e54c45f16d5cc SHA512 75bf94ddc6a30f2c301fcf37dc5ae63a37666626f6c0a7393ff8c868964f10c3345f9e12b7934dd4c5e819cc085e6c294520236a220227d7f6196b27a419a00f
@@ -1,294 +0,0 @@
Fix a crash when a document with no pages is loaded or reloaded, and leaks
when a reload fails to open or authenticate.
https://github.com/dheerajshenoy/lektra/issues/85
https://github.com/dheerajshenoy/lektra/commit/4205f1f2e618d68bc78accdb951e6d2fb01449f7
https://github.com/dheerajshenoy/lektra/commit/6a1d0f6e4bcf23a561f713385d08fa8d7fc404c8
diff --git a/src/Model.cpp b/src/Model.cpp
index 8bb6a42..617d135 100644
--- a/src/Model.cpp
+++ b/src/Model.cpp
@@ -296,6 +296,9 @@ Model::~Model() noexcept
m_render_cancelled.store(true);
waitForPendingRenders();
+ // A document still waiting for its password
+ clearPending();
+
if (m_filetype == FileType::DJVU)
{
cleanup_djvu();
diff --git a/src/documentview/Layout.cpp b/src/documentview/Layout.cpp
index fbe2445..f9df932 100644
--- a/src/documentview/Layout.cpp
+++ b/src/documentview/Layout.cpp
@@ -91,7 +91,7 @@ DocumentView::setLayoutMode(const LayoutMode &mode) noexcept
updateSceneRect();
// Ensure we are in valid page number
- m_pageno = std::clamp(m_pageno, 0, m_model->numPages() - 1);
+ m_pageno = std::clamp(m_pageno, 0, std::max(0, m_model->numPages() - 1));
GotoPage(m_pageno);
}
@@ -113,7 +113,7 @@ DocumentView::setGridColumns(int columns) noexcept
invalidateVisiblePagesCache();
cachePageStride();
updateSceneRect();
- GotoPage(std::clamp(m_pageno, 0, m_model->numPages() - 1));
+ GotoPage(std::clamp(m_pageno, 0, std::max(0, m_model->numPages() - 1)));
}
// Rotate page clockwise
diff --git a/src/documentview/Rendering.cpp b/src/documentview/Rendering.cpp
index 3813054..5dad52a 100644
--- a/src/documentview/Rendering.cpp
+++ b/src/documentview/Rendering.cpp
@@ -139,8 +139,12 @@ DocumentView::getVisiblePages() noexcept
if (m_layout_mode == LayoutMode::SINGLE)
{
- m_visible_pages_cache.insert(
- std::clamp(m_pageno, 0, m_model->numPages() - 1));
+ auto numPages = m_model->numPages();
+ if (numPages <= 0)
+ return m_visible_pages_cache;
+
+ m_visible_pages_cache.insert(std::clamp(m_pageno, 0, numPages - 1));
+
m_visible_pages_dirty = false;
return m_visible_pages_cache;
}
@@ -209,7 +213,10 @@ DocumentView::getVisiblePages() noexcept
// starts below its bottom.
const int C = m_grid_columns;
const int rows = (N + C - 1) / C;
- auto rowEnd = [&](int r) { return m_page_offsets[std::min((r + 1) * C, N)]; };
+ auto rowEnd = [&](int r)
+ {
+ return m_page_offsets[std::min((r + 1) * C, N)];
+ };
int lo = 0, hi = rows;
while (lo < hi)
@@ -671,15 +678,14 @@ DocumentView::startNextRenderJob() noexcept
const PageRenderKey dispatchKey = currentPageRenderKey();
QPointer<DocumentView> self(this);
- m_model->requestPageRender(
- job,
- [self, pageno, dispatchZoom, dispatchKey,
- cancelToken](Model::PageRenderResult result)
+ m_model->requestPageRender(job,
+ [self, pageno, dispatchZoom, dispatchKey,
+ cancelToken](Model::PageRenderResult result)
{
if (!self)
return;
- DocumentView *view = self.data();
+ DocumentView *view = self.data();
const double cbStart = rtrace::enabled() ? rtrace::nowMs() : 0.0;
--view->m_render_slots_used;
@@ -819,7 +825,7 @@ DocumentView::startNextRenderJob() noexcept
view->traceRenderResult(pageno, "applied", cbStart, result);
view->startNextRenderJob();
},
- cancelToken);
+ cancelToken);
}
}
@@ -856,8 +862,7 @@ void
DocumentView::prunePendingRenders(const PageList &visiblePages) noexcept
{
for (auto it = m_pending_renders.begin(); it != m_pending_renders.end();)
- it = inPageList(visiblePages, *it) ? ++it
- : m_pending_renders.erase(it);
+ it = inPageList(visiblePages, *it) ? ++it : m_pending_renders.erase(it);
for (auto it = m_inflight_renders.begin(); it != m_inflight_renders.end();)
{
@@ -1063,7 +1068,10 @@ DocumentView::getPreloadPages(const std::set<int> &visiblePages) noexcept
if (visiblePages.empty())
return {};
- const int numPages = m_model->numPages();
+ const int numPages = m_model->numPages();
+ if (numPages <= 0)
+ return {};
+
const int firstVisible = *visiblePages.begin();
const int lastVisible = *visiblePages.rbegin();
@@ -1375,11 +1383,18 @@ DocumentView::clearVisibleAnnotations() noexcept
int
DocumentView::pageAtAxisCoord(double coord) const noexcept
{
+
const auto it = std::upper_bound(m_page_offsets.cbegin(),
m_page_offsets.cend(), coord);
const int candidate
= static_cast<int>(std::distance(m_page_offsets.cbegin(), it) - 1);
- const int page = std::clamp(candidate, 0, m_model->numPages() - 1);
+
+ const int numPages = m_model->numPages();
+ if (numPages <= 0)
+ return 0;
+
+ const int page = std::clamp(candidate, 0, numPages - 1);
+
// The pages of a row share an offset, so the search lands on the last
// one; the row is represented by its first.
return m_layout_mode == LayoutMode::GRID ? gridRowStart(page) : page;
@@ -1515,7 +1530,8 @@ DocumentView::requestPageRender(int pageno, bool force, bool visible) noexcept
// backdrop) until the button is released.
if (m_minimap_dragging && !force)
{
- const GraphicsImageItem *item = m_page_items_hash.value(pageno, nullptr);
+ const GraphicsImageItem *item
+ = m_page_items_hash.value(pageno, nullptr);
if (item && !item->isNull() && !m_placeholder_pages.contains(pageno))
return;
}
@@ -1679,8 +1695,7 @@ DocumentView::createAndAddPlaceholderPageItem(int pageno) noexcept
// Puts a page item where the current layout wants it.
void
-DocumentView::positionPageItem(GraphicsImageItem *pageItem,
- int pageno) noexcept
+DocumentView::positionPageItem(GraphicsImageItem *pageItem, int pageno) noexcept
{
// Logical scene size of the rendered image.
const QSizeF logicalSize = pageSceneSize(pageno);
@@ -1913,8 +1928,7 @@ DocumentView::gridRowStart(int pageno) const noexcept
int
DocumentView::gridRowEnd(int pageno) const noexcept
{
- return std::min(gridRowStart(pageno) + m_grid_columns,
- m_model->numPages());
+ return std::min(gridRowStart(pageno) + m_grid_columns, m_model->numPages());
}
// Helper: stride (extent + spacing) of a specific page
@@ -1936,8 +1950,8 @@ DocumentView::pageStride(int pageno) const noexcept
if (m_layout_mode == LayoutMode::GRID)
{
// The next row starts after the last page of this one.
- const int nextIdx = std::min(gridRowEnd(pageno),
- static_cast<int>(m_page_offsets.size()) - 1);
+ const int nextIdx = std::min(
+ gridRowEnd(pageno), static_cast<int>(m_page_offsets.size()) - 1);
return m_page_offsets[nextIdx] - m_page_offsets[pageno];
}
diff --git a/src/model/Lifecycle.cpp b/src/model/Lifecycle.cpp
index 2682cb5..2f81b28 100644
--- a/src/model/Lifecycle.cpp
+++ b/src/model/Lifecycle.cpp
@@ -1257,6 +1257,18 @@ Model::_continueOpen(fz_context *ctx, fz_document *doc) noexcept
return;
}
+ // A document without pages (e.g. a PDF that is still being written)
+ // cannot be shown; the rest of the view assumes at least one page.
+ if (page_count <= 0)
+ {
+ fz_warn(ctx, "Document has no pages");
+ fz_drop_document(ctx, doc);
+ fz_drop_context(ctx);
+ QMetaObject::invokeMethod(this, &Model::openFileFailed,
+ Qt::QueuedConnection);
+ return;
+ }
+
QMetaObject::invokeMethod(this, [this, ctx, doc, page_count, w, h]
{
waitForPendingRenders();
@@ -1386,37 +1398,48 @@ Model::reloadDocument() noexcept
// Open the fresh document BEFORE cleanup() drops the old one.
// cleanup() calls fz_drop_document(m_ctx, m_doc) and nulls m_doc,
// so we must have the new handle ready before that happens.
- fz_document *new_doc = nullptr;
- fz_try(m_ctx)
+ //
+ // Nothing with a destructor lives inside fz_try and it is never left with
+ // a return: a MuPDF error jumps straight to fz_catch, skipping destructors
+ // (a lock_guard would stay locked) and an early return would leave the
+ // try frame on MuPDF's stack.
+ fz_document *volatile new_doc = nullptr;
+ bool needsPassword = false;
{
- std::lock_guard<std::mutex> lock(m_doc_mutex);
const QByteArray filePathBytes = m_filepath.toUtf8();
const std::string filePathStr(filePathBytes.constData(),
filePathBytes.size());
- new_doc = open_document_any(m_ctx, filePathStr.c_str());
- if (!new_doc)
- return false;
+ const bool canAuth = m_config.behavior.cache_password
+ && !m_cached_password.isEmpty();
+ const std::string cachedPassword = m_cached_password.toStdString();
- if (fz_needs_password(m_ctx, new_doc))
+ std::lock_guard<std::mutex> lock(m_doc_mutex);
+ fz_try(m_ctx)
{
- const bool canAuth = m_config.behavior.cache_password
- && !m_cached_password.isEmpty();
- const bool authed
- = canAuth
- && fz_authenticate_password(
- m_ctx, new_doc, m_cached_password.toStdString().c_str());
- if (!authed)
- {
+ new_doc = open_document_any(m_ctx, filePathStr.c_str());
+ if (new_doc && fz_needs_password(m_ctx, new_doc)
+ && !(canAuth
+ && fz_authenticate_password(m_ctx, new_doc,
+ cachedPassword.c_str())))
+ needsPassword = true;
+ }
+ fz_catch(m_ctx)
+ {
+ qWarning() << "reloadDocument: failed to open:"
+ << fz_caught_message(m_ctx);
+ if (new_doc)
fz_drop_document(m_ctx, new_doc);
- emit reloadPasswordRequired();
- return false;
- }
+ return false;
}
}
- fz_catch(m_ctx)
+
+ if (!new_doc)
+ return false;
+
+ if (needsPassword)
{
- qWarning() << "reloadDocument: failed to open:"
- << fz_caught_message(m_ctx);
+ fz_drop_document(m_ctx, new_doc);
+ emit reloadPasswordRequired();
return false;
}
@@ -1444,6 +1467,14 @@ Model::reloadDocument() noexcept
return false;
}
+ // Keep the current document if the new file has no pages yet (e.g. it is
+ // still being rewritten); the next change of the file reloads it again.
+ if (page_count <= 0)
+ {
+ fz_drop_document(m_ctx, new_doc);
+ return false;
+ }
+
waitForPendingRenders();
m_render_cancelled.store(false, std::memory_order_release);
cleanup_mupdf();
@@ -5,7 +5,7 @@ EAPI=8
inherit cmake optfeature xdg
MUPDF_PV="1.28.5"
MUPDF_PV="1.28.6"
SYNCTEX_COMMIT="917617707955cde0c2fae127130d9d3129303cbc"
DESCRIPTION="High-performance PDF reader that prioritizes screen space and control"
@@ -40,8 +40,7 @@ BDEPEND="
"
PATCHES=(
"${FILESDIR}/${P}-build-fixes.patch"
"${FILESDIR}/${P}-empty-document.patch"
"${FILESDIR}/${PN}-0.8.0-build-fixes.patch"
)
src_prepare() {
@@ -75,6 +74,7 @@ src_configure() {
-DWITH_LIBARCHIVE=OFF
-DWITH_LLD=OFF
-DWITH_LUA=OFF
-DWITH_MICROTEX=OFF
-DWITH_LLM_SUPPORT=OFF
)
cmake_src_configure