]> git.parisson.com Git - pdf.js.git/commitdiff
Ensure to call the pageDone callback after it's really done
authorJulian Viereck <julian.viereck@gmail.com>
Fri, 9 Sep 2011 16:24:31 +0000 (09:24 -0700)
committerJulian Viereck <julian.viereck@gmail.com>
Thu, 15 Sep 2011 16:05:04 +0000 (09:05 -0700)
pdf.js

diff --git a/pdf.js b/pdf.js
index f41160ebbeaf194d9e8b981b866d7b9818ab8667..44873a744844792370789ae936b277cf1b56e8bc 100644 (file)
--- a/pdf.js
+++ b/pdf.js
@@ -3386,13 +3386,12 @@ var Page = (function() {
         // Firefox error reporting from XHR callbacks.
         setTimeout(function() {
           var exc = null;
-          // try {
-            self.display(gfx);
-            self.stats.render = Date.now();
-          // } catch (e) {
-          //   exc = e.toString();
-          // }
-          continuation(exc);
+          try {
+            self.display(gfx, continuation);
+          } catch (e) {
+            exc = e.toString();
+            continuation(exc);
+          }
         });
       };
       
@@ -3446,7 +3445,7 @@ var Page = (function() {
       );
     },
     
-    display: function(gfx) {
+    display: function(gfx, callback) {
       var xref = this.xref;
       var resources = xref.fetchIfRef(this.resources);
       var mediaBox = xref.fetchIfRef(this.mediaBox);
@@ -3460,8 +3459,13 @@ var Page = (function() {
       var length = this.IRQueue.fnArray.length;
       var IRQueue = this.IRQueue;
       
+      var self = this;
       function next() {
         startIdx = gfx.executeIRQueue(IRQueue, startIdx, next);
+        if (startIdx == length) {
+          self.stats.render = Date.now();
+          callback();
+        }
       }
       next();
     },