From dffc42d234b7f2117d1846baaba23e575a166860 Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Mon, 28 Mar 2016 21:23:33 -0700 Subject: [PATCH] fix(readerrolling): crash with legacy last_per config in page mode --- frontend/apps/reader/modules/readerrolling.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/frontend/apps/reader/modules/readerrolling.lua b/frontend/apps/reader/modules/readerrolling.lua index 9ab3fc0c2..b4a08c0c1 100644 --- a/frontend/apps/reader/modules/readerrolling.lua +++ b/frontend/apps/reader/modules/readerrolling.lua @@ -180,12 +180,21 @@ function ReaderRolling:onReadSettings(config) self.ui.document:gotoXPointer(self.xpointer) end) -- we read last_percent just for backward compatibility + -- FIXME: remove this branch with migration script elseif last_per then table.insert(self.ui.postInitCallback, function() self:_gotoPercent(last_per) - -- we have to do a real pos change in self.ui.document._document + -- _gotoPercent calls _gotoPos, which only updates self.current_pos + -- and self.view. + -- we need to do a real pos change in self.ui.document._document -- to update status information in CREngine. self.ui.document:gotoPos(self.current_pos) + -- _gotoPercent already calls gotoPos, so no need to emit + -- PosUpdate event in scroll mode + if self.view.view_mode == "page" then + self.ui:handleEvent( + Event:new("PageUpdate", self.ui.document:getCurrentPage())) + end self.xpointer = self.ui.document:getXPointer() end) else