Ensure that printing, triggered from scripting, won't accidentally throw in PDFScriptingManager._updateFromSandbox
(#13104)
The issue that this patch fixes is extremely unlikely, but still theoretically possible, and I really should've caught this earlier.
Note how `BaseViewer.pagesPromise` will only be defined when a document is active, see below, and that if a printing event (triggered from scripting) arrives while the document is been closed there's a small chance that the promise isn't defined.
eb92ed12f2/web/base_viewer.js (L426-L428)
This commit is contained in:
parent
dd3797a325
commit
d92b77e87f
@ -260,7 +260,7 @@ class PDFScriptingManager {
|
|||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_updateFromSandbox(detail) {
|
async _updateFromSandbox(detail) {
|
||||||
const { id, command, value } = detail;
|
const { id, command, value } = detail;
|
||||||
if (!id) {
|
if (!id) {
|
||||||
switch (command) {
|
switch (command) {
|
||||||
@ -277,9 +277,8 @@ class PDFScriptingManager {
|
|||||||
this._pdfViewer.currentPageNumber = value + 1;
|
this._pdfViewer.currentPageNumber = value + 1;
|
||||||
break;
|
break;
|
||||||
case "print":
|
case "print":
|
||||||
this._pdfViewer.pagesPromise.then(() => {
|
await this._pdfViewer.pagesPromise;
|
||||||
this._eventBus.dispatch("print", { source: this });
|
this._eventBus.dispatch("print", { source: this });
|
||||||
});
|
|
||||||
break;
|
break;
|
||||||
case "println":
|
case "println":
|
||||||
console.log(value);
|
console.log(value);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user