mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
ReaderHighlight: nil guard a few self.hold_pos accesses (#7700)
Fix #7698 That only leaves a single unguarded access in onUnhighlight
This commit is contained in:
@@ -981,7 +981,7 @@ Copy the language data files for Tesseract 3.04 (e.g., eng.traineddata for Engli
|
||||
|
||||
function ReaderHighlight:lookup(selected_word, selected_link)
|
||||
-- if we extracted text directly
|
||||
if selected_word.word then
|
||||
if selected_word.word and self.hold_pos then
|
||||
local word_box = self.view:pageToScreenTransform(self.hold_pos.page, selected_word.sbox)
|
||||
self.ui:handleEvent(Event:new("LookupWord", selected_word.word, false, word_box, self, selected_link))
|
||||
-- or we will do OCR
|
||||
@@ -1135,7 +1135,7 @@ function ReaderHighlight:translate(selected_text)
|
||||
if selected_text.text ~= "" then
|
||||
self:onTranslateText(selected_text.text)
|
||||
-- or we will do OCR
|
||||
else
|
||||
elseif self.hold_pos then
|
||||
local text = self.ui.document:getOCRText(self.hold_pos.page, selected_text)
|
||||
logger.dbg("OCRed text:", text)
|
||||
if text and text ~= "" then
|
||||
@@ -1262,6 +1262,7 @@ function ReaderHighlight:onUnhighlight(bookmark_item)
|
||||
sel_pos0 = bookmark_item.pos0
|
||||
datetime = bookmark_item.datetime
|
||||
else -- called from DictQuickLookup Unhighlight button
|
||||
--- @fixme: is this self.hold_pos access safe?
|
||||
page = self.hold_pos.page
|
||||
sel_text = cleanupSelectedText(self.selected_text.text)
|
||||
sel_pos0 = self.selected_text.pos0
|
||||
@@ -1336,9 +1337,8 @@ end
|
||||
function ReaderHighlight:saveHighlight()
|
||||
self.ui:handleEvent(Event:new("AddHighlight"))
|
||||
logger.dbg("save highlight")
|
||||
local page = self.hold_pos.page
|
||||
if self.hold_pos and self.selected_text and self.selected_text.pos0
|
||||
and self.selected_text.pos1 then
|
||||
if self.hold_pos and self.selected_text and self.selected_text.pos0 and self.selected_text.pos1 then
|
||||
local page = self.hold_pos.page
|
||||
if not self.view.highlight.saved[page] then
|
||||
self.view.highlight.saved[page] = {}
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user