diff --git a/frontend/apps/reader/modules/readerhighlight.lua b/frontend/apps/reader/modules/readerhighlight.lua index 9bebadd82..fb0bdae12 100644 --- a/frontend/apps/reader/modules/readerhighlight.lua +++ b/frontend/apps/reader/modules/readerhighlight.lua @@ -379,6 +379,10 @@ function ReaderHighlight:clear(clear_id) end end self.clear_id = nil -- invalidate id + if not self.ui.document then + -- might happen if scheduled and run after document is closed + return + end if self.ui.document.info.has_pages then self.view.highlight.temp = {} else diff --git a/frontend/ui/widget/dictquicklookup.lua b/frontend/ui/widget/dictquicklookup.lua index bc314bd44..3d45cf472 100644 --- a/frontend/ui/widget/dictquicklookup.lua +++ b/frontend/ui/widget/dictquicklookup.lua @@ -75,7 +75,7 @@ function DictQuickLookup:canSearch() end else -- This is to prevent an ineffective button when we're launched from the Reader's menu. - if self.ui.highlight.selected_text then + if self.highlight then return true end end diff --git a/frontend/ui/widget/textwidget.lua b/frontend/ui/widget/textwidget.lua index 13409b92f..2837352cc 100644 --- a/frontend/ui/widget/textwidget.lua +++ b/frontend/ui/widget/textwidget.lua @@ -214,6 +214,9 @@ function TextWidget:_measureWithXText() -- no bold: xtext does synthetized bold with normal metrics end local max_width = self.max_width - reserved_width + if max_width <= 0 then -- avoid _xtext:makeLine() crash + max_width = self.max_width + end if self.truncate_left then line_start = self._xtext:getSegmentFromEnd(max_width) end @@ -311,7 +314,6 @@ end function TextWidget:setText(text) if text ~= self.text then self.text = text - self._updated = false self:free() end end @@ -324,7 +326,6 @@ dbg:guard(TextWidget, "setText", function TextWidget:setMaxWidth(max_width) if max_width ~= self.max_width then self.max_width = max_width - self._updated = false self:free() end end @@ -378,6 +379,7 @@ function TextWidget:free() self._xtext:free() self._xtext = nil end + self._updated = false end function TextWidget:onCloseWidget()