[Pkg-javascript-commits] [pdf.js] 91/174: Prevent `TypeError: page is undefined` when the document has been destroyed (PR 6546 follow-up)
David Prévot
taffit at moszumanska.debian.org
Thu Nov 19 18:45:20 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository pdf.js.
commit 5bd95df42761411ba83abe4437e5aa1a4af80f10
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date: Fri Oct 23 20:44:18 2015 +0200
Prevent `TypeError: page is undefined` when the document has been destroyed (PR 6546 follow-up)
*Follow-up to PR 6546.*
If rendering has already started when the document is destroyed, then `this.pageCache[data.pageIndex]` may already have been cleared when the `StartRenderingPage`/`RenderPageChunk` messages are recieved in `api.js`, which results in `TypeError`s being thrown.
---
src/display/api.js | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/display/api.js b/src/display/api.js
index fb47469..f097bca 100644
--- a/src/display/api.js
+++ b/src/display/api.js
@@ -1233,6 +1233,9 @@ var WorkerTransport = (function WorkerTransportClosure() {
}, this);
messageHandler.on('StartRenderPage', function transportRender(data) {
+ if (this.destroyed) {
+ return; // Ignore any pending requests if the worker was terminated.
+ }
var page = this.pageCache[data.pageIndex];
page.stats.timeEnd('Page Request');
@@ -1240,6 +1243,9 @@ var WorkerTransport = (function WorkerTransportClosure() {
}, this);
messageHandler.on('RenderPageChunk', function transportRender(data) {
+ if (this.destroyed) {
+ return; // Ignore any pending requests if the worker was terminated.
+ }
var page = this.pageCache[data.pageIndex];
page._renderPageChunk(data.operatorList, data.intent);
--
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