From 8556d77f557b787292f9a96f7667e729e5a4d2b2 Mon Sep 17 00:00:00 2001 From: yparitcher Date: Wed, 16 Apr 2025 12:31:37 -0400 Subject: [PATCH] ReaderPaging:onRestoreBookLocation Copy location / ctx so it does not get modified Fixes: #13570 --- frontend/apps/reader/modules/readerpaging.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/frontend/apps/reader/modules/readerpaging.lua b/frontend/apps/reader/modules/readerpaging.lua index b9b59b17c..edc760e56 100644 --- a/frontend/apps/reader/modules/readerpaging.lua +++ b/frontend/apps/reader/modules/readerpaging.lua @@ -599,8 +599,11 @@ function ReaderPaging:onRestoreBookLocation(saved_location) if not saved_location or not saved_location[1] then return end + -- We need a copy, as we will assign this to ReaderView.state + -- which when modified would change our instance on ReaderLink.location_stack + local ctx = util.tableDeepCopy(saved_location) if self.view.page_scroll then - if self.view:restoreViewContext(saved_location) then + if self.view:restoreViewContext(ctx) then self:_gotoPage(saved_location[1].page, "scrolling") else -- If context is unusable (not from scroll mode), trigger @@ -615,7 +618,7 @@ function ReaderPaging:onRestoreBookLocation(saved_location) -- PageUpdate event - so we need to do it for a correct redrawing local send_PageUpdate = saved_location[1].page == self.current_page self:_gotoPage(saved_location[1].page) - if not self.view:restoreViewContext(saved_location) then + if not self.view:restoreViewContext(ctx) then -- If context is unusable (not from page mode), also -- send PageUpdate event to go to its page and redraw it send_PageUpdate = true