]> git.parisson.com Git - pdf.js.git/commitdiff
Fixes content stream reset; terminating rendering when destroyed
authorYury Delendik <ydelendik@mozilla.com>
Mon, 16 Apr 2012 21:46:26 +0000 (16:46 -0500)
committerYury Delendik <ydelendik@mozilla.com>
Mon, 16 Apr 2012 21:46:26 +0000 (16:46 -0500)
src/api.js
src/core.js

index 189b94dbe1547985198aa4292200fa060bce09aa..dfc245b03167108da2e95d9aeb915683d5473f99 100644 (file)
@@ -233,6 +233,11 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
       // Once the operatorList and fonts are loaded, do the actual rendering.
       this.displayReadyPromise.then(
         function pageDisplayReadyPromise() {
+          if (self.destroyed) {
+            complete();
+            return;
+          }
+
           var gfx = new CanvasGraphics(params.canvasContext,
             this.objs, params.textLayer);
           try {
@@ -351,8 +356,8 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
       this.destroyed = true;
 
       if (!this.renderInProgress) {
-        delete self.operatorList;
-        delete self.displayReadyPromise;
+        delete this.operatorList;
+        delete this.displayReadyPromise;
       }
     }
   };
index cbd2abf8d5e084395e2ef696e94e306ff1fcc2db..2734d0eef7c19a6d3df6cf23d3c48a2a72a366f3 100644 (file)
@@ -137,10 +137,13 @@ var Page = (function PageClosure() {
       var resources = this.resources;
       if (isArray(content)) {
         // fetching items
+        var streams = [];
         var i, n = content.length;
         for (i = 0; i < n; ++i)
-          content[i] = xref.fetchIfRef(content[i]);
-        content = new StreamsSequenceStream(content);
+          streams.push(xref.fetchIfRef(content[i]));
+        content = new StreamsSequenceStream(streams);
+      } else if (isStream(content)) {
+        content.reset();
       } else if (!content) {
         // replacing non-existent page content with empty one
         content = new Stream(new Uint8Array(0));