2
0
mirror of https://github.com/koreader/koreader synced 2024-11-10 01:10:34 +00:00

ReaderView: Don't crash on pre-#11044 highlights without a color field (#12438)

(They'll be drawn in gray, as before)

Regression since #11044
(https://github.com/koreader/koreader/pull/11044#issuecomment-2322820971)
This commit is contained in:
NiLuJe 2024-08-31 22:55:59 +02:00 committed by GitHub
parent 49e885321a
commit cf83dc8bd3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View File

@ -546,7 +546,7 @@ function ReaderView:drawPageSavedHighlight(bb, x, y)
for _, item in ipairs(items) do
local boxes = self.document:getPageBoxesFromPositions(page, item.pos0, item.pos1)
if boxes then
local color = Blitbuffer.colorFromName(item.color)
local color = item.color and Blitbuffer.colorFromName(item.color)
if color and not Blitbuffer.isColor8(color) then
colorful = true
end
@ -592,7 +592,7 @@ function ReaderView:drawXPointerSavedHighlight(bb, x, y)
if end_pos >= cur_view_top then
local boxes = self.document:getScreenBoxesFromPositions(item.pos0, item.pos1, true) -- get_segments=true
if boxes then
local color = Blitbuffer.colorFromName(item.color)
local color = item.color and Blitbuffer.colorFromName(item.color)
if color and not Blitbuffer.isColor8(color) then
colorful = true
end

View File

@ -245,7 +245,7 @@ function PdfDocument:saveHighlight(pageno, item)
local quadpoints, n = _quadpointsFromPboxes(item.pboxes)
local page = self._document:openPage(pageno)
local annot_type = C.PDF_ANNOT_HIGHLIGHT
local annot_color = BlitBuffer.colorFromName(item.color)
local annot_color = item.color and BlitBuffer.colorFromName(item.color)
if item.drawer == "lighten" then
annot_type = C.PDF_ANNOT_HIGHLIGHT
elseif item.drawer == "underscore" then