mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
reordered freeing of resources, error handling for doc open
This commit is contained in:
@@ -117,18 +117,12 @@ end
|
||||
|
||||
-- open a PDF file and its settings store
|
||||
function PDFReader:open(filename, password)
|
||||
if self.doc ~= nil then
|
||||
self.doc:close()
|
||||
end
|
||||
if self.settings ~= nil then
|
||||
self.settings:close()
|
||||
end
|
||||
|
||||
self.doc = pdf.openDocument(filename, password or "")
|
||||
if self.doc ~= nil then
|
||||
self.settings = DocSettings:open(filename)
|
||||
self:clearcache()
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- set viewer state according to zoom state
|
||||
@@ -275,8 +269,14 @@ function PDFReader:inputloop()
|
||||
self:goto(self.pageno - 1)
|
||||
end
|
||||
elseif ev.code == KEY_BACK then
|
||||
self.settings:savesetting("last_page", self.pageno)
|
||||
self.settings:close()
|
||||
self:clearcache()
|
||||
if self.doc ~= nil then
|
||||
self.doc:close()
|
||||
end
|
||||
if self.settings ~= nil then
|
||||
self.settings:savesetting("last_page", self.pageno)
|
||||
self.settings:close()
|
||||
end
|
||||
return
|
||||
elseif ev.code == KEY_VPLUS then
|
||||
self:modify_gamma( 1.25 )
|
||||
|
||||
Reference in New Issue
Block a user