From: Yury Delendik Date: Mon, 16 Apr 2012 21:46:26 +0000 (-0500) Subject: Fixes content stream reset; terminating rendering when destroyed X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=b6edbb38c1eafa35044408bd8eaa2e045d5378a0;p=pdf.js.git Fixes content stream reset; terminating rendering when destroyed --- diff --git a/src/api.js b/src/api.js index 189b94d..dfc245b 100644 --- a/src/api.js +++ b/src/api.js @@ -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; } } }; diff --git a/src/core.js b/src/core.js index cbd2abf..2734d0e 100644 --- a/src/core.js +++ b/src/core.js @@ -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));