make sure ReaderLink gets a deep copy of location

Fixes: #7922
pull/7934/head
yparitcher 3 years ago
parent 246b402d9c
commit b07414c2b5

@ -32,16 +32,7 @@ end
function ReaderBack:_getCurrentLocation() function ReaderBack:_getCurrentLocation()
if self.ui.document.info.has_pages then if self.ui.document.info.has_pages then
local current_location = self.ui.paging:getBookLocation() return self.ui.paging:getBookLocation()
if current_location then
-- We need a copy, as we're getting references to
-- objects ReaderPaging/ReaderView may still modify
local res = {}
for i=1, #current_location do
res[i] = util.tableDeepCopy(current_location[i])
end
return res
end
else else
return { return {
xpointer = self.ui.rolling:getBookLocation(), xpointer = self.ui.rolling:getBookLocation(),

@ -11,6 +11,7 @@ local TimeVal = require("ui/timeval")
local UIManager = require("ui/uimanager") local UIManager = require("ui/uimanager")
local bit = require("bit") local bit = require("bit")
local logger = require("logger") local logger = require("logger")
local util = require("util")
local _ = require("gettext") local _ = require("gettext")
local Input = Device.input local Input = Device.input
local Screen = Device.screen local Screen = Device.screen
@ -683,8 +684,18 @@ function ReaderPaging:onPanningRel(diff)
return true return true
end end
-- Used by ReaderBack & ReaderLink.
function ReaderPaging:getBookLocation() 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 end
function ReaderPaging:onRestoreBookLocation(saved_location) function ReaderPaging:onRestoreBookLocation(saved_location)

Loading…
Cancel
Save