diff --git a/resources/compiled_coffeescript.zip b/resources/compiled_coffeescript.zip index e092b53157..3c5f0e80c6 100644 Binary files a/resources/compiled_coffeescript.zip and b/resources/compiled_coffeescript.zip differ diff --git a/src/calibre/ebooks/oeb/display/indexing.coffee b/src/calibre/ebooks/oeb/display/indexing.coffee index efe42199e9..357128fce9 100644 --- a/src/calibre/ebooks/oeb/display/indexing.coffee +++ b/src/calibre/ebooks/oeb/display/indexing.coffee @@ -50,6 +50,8 @@ class BookIndexing this.last_check = [null, null] cache_valid: (anchors) -> + if not anchors + return false for a in anchors if not Object.prototype.hasOwnProperty.call(this.cache, a) return false @@ -65,6 +67,8 @@ class BookIndexing return this.cache ans = {} + if not anchors + return ans for anchor in anchors elem = document.getElementById(anchor) if elem == null diff --git a/src/calibre/gui2/viewer/main.py b/src/calibre/gui2/viewer/main.py index 113e1201e2..8681a0fe21 100644 --- a/src/calibre/gui2/viewer/main.py +++ b/src/calibre/gui2/viewer/main.py @@ -772,12 +772,14 @@ class EbookViewer(MainWindow, Ui_EbookViewer): self.scrolled(self.view.scroll_fraction) def internal_link_clicked(self, frac): + self.update_page_number() # Ensure page number is accurate as it is used for history self.history.add(self.pos.value()) def link_clicked(self, url): path = os.path.abspath(unicode(url.toLocalFile())) frag = None if path in self.iterator.spine: + self.update_page_number() # Ensure page number is accurate as it is used for history self.history.add(self.pos.value()) path = self.iterator.spine[self.iterator.spine.index(path)] if url.hasFragment(): @@ -913,6 +915,14 @@ class EbookViewer(MainWindow, Ui_EbookViewer): else: self.view.document.page_position.restore() self.view.document.after_resize() + # For some reason scroll_fraction returns incorrect results in paged + # mode for some time after a resize is finished. No way of knowing + # exactly how long, so we update it in a second, in the hopes that it + # will be enough *most* of the time. + QTimer.singleShot(1000, self.update_page_number) + + def update_page_number(self): + self.set_page_number(self.view.document.scroll_fraction) def close_progress_indicator(self): self.pi.stop()