CreDocument: fix document loading interferences (#4349)

When a main document is opened for displaying, some other
document openings (for getting metadata or cover image)
could affect the main document.
Split some code from CreDocument:init() into another new
method CreDocument:setupDefaultView(), that will only be
called by ReaderUI when opening the main document (and not
by these other openings like Book inforation, View cover...)

Also speed up some of these other openings (Search, Screensaver)
by using doc:loadDocument(false) to load only metadata and
avoid parsing the HTML.

Details in https://github.com/koreader/koreader/issues/4346#issuecomment-440036496
This commit is contained in:
poire-z
2018-11-20 21:07:59 +01:00
committed by Frans de Jonge
parent 872c908a02
commit 85ac59ae00
5 changed files with 40 additions and 13 deletions

View File

@@ -263,6 +263,11 @@ function ReaderUI:init()
document = self.document,
})
else
-- load crengine default settings (from cr3.ini, some of these
-- will be overriden by our settings by some reader modules below)
if self.document.setupDefaultView then
self.document:setupDefaultView()
end
-- make sure we render document first before calling any callback
self:registerPostInitCallback(function()
if not self.document:loadDocument() then