[Pkg-javascript-commits] [pdf.js] 232/414: Remove the `hasImage` property from `PDFThumbnailView`

David Prévot taffit at moszumanska.debian.org
Tue Jun 28 17:12:25 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository pdf.js.

commit 95aa8b0415592176ce0bf00e88354a9e50be6979
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date:   Thu Feb 25 16:47:51 2016 +0100

    Remove the `hasImage` property from `PDFThumbnailView`
    
    The `hasImage` property is a left-over from older thumbnail code, and has been made obsolete by `renderingState`.
    Having two different properties tracking (basically) the same state is asking for trouble, since it's very easy to forget to update one of them, with annoying bugs as the result.
---
 web/pdf_thumbnail_view.js | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/web/pdf_thumbnail_view.js b/web/pdf_thumbnail_view.js
index 13bcd5b..4406f65 100644
--- a/web/pdf_thumbnail_view.js
+++ b/web/pdf_thumbnail_view.js
@@ -77,7 +77,6 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
     this.linkService = linkService;
     this.renderingQueue = renderingQueue;
 
-    this.hasImage = false;
     this.resume = null;
     this.renderingState = RenderingStates.INITIAL;
 
@@ -133,7 +132,6 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
       if (this.renderTask) {
         this.renderTask.cancel();
       }
-      this.hasImage = false;
       this.resume = null;
       this.renderingState = RenderingStates.INITIAL;
 
@@ -238,11 +236,9 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
     draw: function PDFThumbnailView_draw() {
       if (this.renderingState !== RenderingStates.INITIAL) {
         console.error('Must be in new state before drawing');
-      }
-      if (this.hasImage) {
         return Promise.resolve(undefined);
       }
-      this.hasImage = true;
+
       this.renderingState = RenderingStates.RUNNING;
 
       var resolveRenderPromise, rejectRenderPromise;
@@ -263,6 +259,7 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
           rejectRenderPromise(error);
           return;
         }
+
         self.renderingState = RenderingStates.FINISHED;
         self._convertCanvasToImage();
 
@@ -306,14 +303,17 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
     },
 
     setImage: function PDFThumbnailView_setImage(pageView) {
+      if (this.renderingState !== RenderingStates.INITIAL) {
+        return;
+      }
       var img = pageView.canvas;
-      if (this.hasImage || !img) {
+      if (!img) {
         return;
       }
       if (!this.pdfPage) {
         this.setPdfPage(pageView.pdfPage);
       }
-      this.hasImage = true;
+
       this.renderingState = RenderingStates.FINISHED;
 
       var ctx = this._getPageDrawContext(true);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git



More information about the Pkg-javascript-commits mailing list