languagesupport: check that ui.languagesupport is non-nil

Now that FileManager registers its UI modules in the same way as Reader,
this shouldn't be necessary but this protects us against some other app
creating a ReaderDictionary instance without having ui.languagesupport
registered properly.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
pull/8379/head
Aleksa Sarai 3 years ago committed by poire-z
parent cdbedcbcce
commit de7c1e20c5

@ -801,7 +801,7 @@ end
function ReaderDictionary:startSdcv(word, dict_names, fuzzy_search)
local words = {word}
if self.ui.languagesupport:hasActiveLanguagePlugins() then
if self.ui.languagesupport and self.ui.languagesupport:hasActiveLanguagePlugins() then
-- Get any other candidates from any language-specific plugins we have.
-- We prefer the originally selected word first (in case there is a
-- dictionary entry for whatever text the user selected).

@ -864,7 +864,7 @@ function ReaderHighlight:onHold(arg, ges)
self.selected_link = link
end
if self.ui.languagesupport:hasActiveLanguagePlugins() then
if self.ui.languagesupport and self.ui.languagesupport:hasActiveLanguagePlugins() then
-- If this is a language where pan-less word selection needs some
-- extra work above and beyond what the document engine gives us
-- from getWordFromPosition, call the relevant language-specific
@ -1338,7 +1338,7 @@ function ReaderHighlight:highlightFromHoldPos()
if self.hold_pos then
if not self.selected_text then
self.selected_text = self.ui.document:getTextFromPositions(self.hold_pos, self.hold_pos)
if self.ui.languagesupport:hasActiveLanguagePlugins() then
if self.ui.languagesupport and self.ui.languagesupport:hasActiveLanguagePlugins() then
-- Match language-specific expansion you'd get from self:onHold().
local new_selected_text = self.ui.languagesupport:improveWordSelection(self.selected_text)
if new_selected_text then

Loading…
Cancel
Save