make sure ReaderLink gets a deep copy of location

Fixes: #7922
This commit is contained in:
yparitcher
2021-07-02 11:11:26 -04:00
parent 246b402d9c
commit b07414c2b5
2 changed files with 13 additions and 11 deletions

View File

@@ -11,6 +11,7 @@ local TimeVal = require("ui/timeval")
local UIManager = require("ui/uimanager")
local bit = require("bit")
local logger = require("logger")
local util = require("util")
local _ = require("gettext")
local Input = Device.input
local Screen = Device.screen
@@ -683,8 +684,18 @@ function ReaderPaging:onPanningRel(diff)
return true
end
-- Used by ReaderBack & ReaderLink.
function ReaderPaging:getBookLocation()
return self.view:getViewContext()
local ctx = self.view:getViewContext()
if ctx then
-- We need a copy, as we're getting references to
-- objects ReaderPaging/ReaderView may still modify
local current_location = {}
for i=1, #ctx do
current_location[i] = util.tableDeepCopy(ctx[i])
end
return current_location
end
end
function ReaderPaging:onRestoreBookLocation(saved_location)