From e401804f13fc76b63b7aa68021c11bf45ecd4d49 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Fri, 22 Jan 2016 13:28:30 +0100 Subject: [PATCH] Remove the 'oplist' rendering intent when `getOperatorList` has returned the complete `OperatorList`, and prevent errors in `PDFPageProxy_destroy` for the 'oplist' rendering intent --- src/display/api.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/display/api.js b/src/display/api.js index 96e577426..8ee45c078 100644 --- a/src/display/api.js +++ b/src/display/api.js @@ -1034,6 +1034,11 @@ var PDFPageProxy = (function PDFPageProxyClosure() { function operatorListChanged() { if (intentState.operatorList.lastChunk) { intentState.opListReadCapability.resolve(intentState.operatorList); + + var i = intentState.renderTasks.indexOf(opListTask); + if (i >= 0) { + intentState.renderTasks.splice(i, 1); + } } } @@ -1042,9 +1047,10 @@ var PDFPageProxy = (function PDFPageProxyClosure() { this.intentStates[renderingIntent] = Object.create(null); } var intentState = this.intentStates[renderingIntent]; + var opListTask; if (!intentState.opListReadCapability) { - var opListTask = {}; + opListTask = {}; opListTask.operatorListChanged = operatorListChanged; intentState.receivingOperatorList = true; intentState.opListReadCapability = createPromiseCapability(); @@ -1087,6 +1093,10 @@ var PDFPageProxy = (function PDFPageProxyClosure() { var waitOn = []; Object.keys(this.intentStates).forEach(function(intent) { + if (intent === 'oplist') { + // Avoid errors below, since the renderTasks are just stubs. + return; + } var intentState = this.intentStates[intent]; intentState.renderTasks.forEach(function(renderTask) { var renderCompleted = renderTask.capability.promise.