D14752: Fix links being "lost" on save
Tobias Deiminger
noreply at phabricator.kde.org
Mon Aug 13 08:18:01 BST 2018
tobiasdeiminger added a comment.
@sander Here's a bit of explanation how I understand it. Maybe you can extract comments / commit message / documentation from it.
"ctrl+s" saves a modified PDF to file, and then uses "hot-swap" (43a3756e1 <https://phabricator.kde.org/R223:43a3756e1c77b7e4ffebb26bdd024613fa1f4e18>) for reload. Hot-swapping replaces in-memory core document data, while leaving the UI unaffected (stay at current page, don't reload rasterized page images).
Each Page object has a list of rectangular areas (Page::m_rects), that indicate where the UI must be sensitive for mouse-over and click. The rectangles refer to different objects, like annotations and actions. In the case of PDF links, a generator is supposed to setup these rectangular areas as ObjectRect::Action and push them into a Page via Okular::Page::setObjectRects.
PDFGenerator deferrers link setup. Initially on document load, links are cleared and empty. Link setup is postponed until a page is first rendered with PDFGenerator::image. Page rendering happens on-demand (depending on PageView scroll position, thumbnails preview, ...) and is async und unrelated to document loading. The first render request for a page causes all links for that page to be setup. The PDFGenerator has a bit array rectsGenerated to remember which page has already been setup with links (one bit per page).
In the bug, Page::m_rects was empty after hot-swapping, because PDFGenerator depends on PDFGenerator::image to generate them. But PDFGenerator::image did not happen, as it is deliberately not tied to hot-swap. So the links are potentially never generated.
Some more details on hot-swapping: Document::swapBackingFile calls Generator::swapBackingFile to generate new Page models. It then moves the d-Pointer and most inner content of the new (temporary) pages into the previously existing Page objects. The existing Page objects are kept intact, because they're referenced by UI. Most old data is deleted, but few things like Page::m_pixmaps and Page::m_boundingBox are preserved from the former Pages. Most interestingly, link rectangles in Page::m_rects are replaced with the new m_rects from Generator.
REPOSITORY
R223 Okular
REVISION DETAIL
https://phabricator.kde.org/D14752
To: aacid
Cc: tobiasdeiminger, sander, okular-devel, ngraham, aacid
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/okular-devel/attachments/20180813/ae485933/attachment-0001.html>
More information about the Okular-devel
mailing list