Merge pull request #19135 from Snuffleupagus/api-more-optional-chaining
Use even more optional chaining in the `src/display/api.js` file
This commit is contained in:
commit
1bc6b767c2
@ -655,23 +655,26 @@ class PDFDocumentLoadingTask {
|
|||||||
*/
|
*/
|
||||||
async destroy() {
|
async destroy() {
|
||||||
this.destroyed = true;
|
this.destroyed = true;
|
||||||
try {
|
|
||||||
if (this._worker?.port) {
|
|
||||||
this._worker._pendingDestroy = true;
|
|
||||||
}
|
|
||||||
await this._transport?.destroy();
|
|
||||||
} catch (ex) {
|
|
||||||
if (this._worker?.port) {
|
|
||||||
delete this._worker._pendingDestroy;
|
|
||||||
}
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
|
|
||||||
this._transport = null;
|
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
||||||
if (this._worker) {
|
await this._transport?.destroy();
|
||||||
this._worker.destroy();
|
} else {
|
||||||
this._worker = null;
|
try {
|
||||||
|
if (this._worker?.port) {
|
||||||
|
this._worker._pendingDestroy = true;
|
||||||
|
}
|
||||||
|
await this._transport?.destroy();
|
||||||
|
} catch (ex) {
|
||||||
|
if (this._worker?.port) {
|
||||||
|
delete this._worker._pendingDestroy;
|
||||||
|
}
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
this._transport = null;
|
||||||
|
|
||||||
|
this._worker?.destroy();
|
||||||
|
this._worker = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2336,17 +2339,16 @@ class PDFWorker {
|
|||||||
*/
|
*/
|
||||||
destroy() {
|
destroy() {
|
||||||
this.destroyed = true;
|
this.destroyed = true;
|
||||||
if (this._webWorker) {
|
|
||||||
// We need to terminate only web worker created resource.
|
// We need to terminate only web worker created resource.
|
||||||
this._webWorker.terminate();
|
this._webWorker?.terminate();
|
||||||
this._webWorker = null;
|
this._webWorker = null;
|
||||||
}
|
|
||||||
PDFWorker.#workerPorts?.delete(this._port);
|
PDFWorker.#workerPorts?.delete(this._port);
|
||||||
this._port = null;
|
this._port = null;
|
||||||
if (this._messageHandler) {
|
|
||||||
this._messageHandler.destroy();
|
this._messageHandler?.destroy();
|
||||||
this._messageHandler = null;
|
this._messageHandler = null;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2600,10 +2602,9 @@ class WorkerTransport {
|
|||||||
new AbortException("Worker was terminated.")
|
new AbortException("Worker was terminated.")
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this.messageHandler) {
|
this.messageHandler?.destroy();
|
||||||
this.messageHandler.destroy();
|
this.messageHandler = null;
|
||||||
this.messageHandler = null;
|
|
||||||
}
|
|
||||||
this.destroyCapability.resolve();
|
this.destroyCapability.resolve();
|
||||||
}, this.destroyCapability.reject);
|
}, this.destroyCapability.reject);
|
||||||
return this.destroyCapability.promise;
|
return this.destroyCapability.promise;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user