mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Merge pull request #12758 from Snuffleupagus/AnnotationStorage-rm-event
Run `AnnotationStorage.resetModified` when destroying the `PDFDocumentLoadingTask`/`PDFDocumentProxy`
This commit is contained in:
commit
1c8ead133a
2 changed files with 44 additions and 20 deletions
|
@ -2127,6 +2127,10 @@ class WorkerTransport {
|
|||
this.setupMessageHandler();
|
||||
}
|
||||
|
||||
get loadingTaskSettled() {
|
||||
return this.loadingTask._capability.settled;
|
||||
}
|
||||
|
||||
destroy() {
|
||||
if (this.destroyCapability) {
|
||||
return this.destroyCapability.promise;
|
||||
|
@ -2154,6 +2158,18 @@ class WorkerTransport {
|
|||
// We also need to wait for the worker to finish its long running tasks.
|
||||
const terminated = this.messageHandler.sendWithPromise("Terminate", null);
|
||||
waitOn.push(terminated);
|
||||
// Allow `AnnotationStorage`-related clean-up when destroying the document.
|
||||
if (this.loadingTaskSettled) {
|
||||
const annotationStorageResetModified = this.loadingTask.promise
|
||||
.then(pdfDocument => {
|
||||
// Avoid initializing the `annotationStorage` if it doesn't exist.
|
||||
if (pdfDocument.hasOwnProperty("annotationStorage")) {
|
||||
pdfDocument.annotationStorage.resetModified();
|
||||
}
|
||||
})
|
||||
.catch(() => {});
|
||||
waitOn.push(annotationStorageResetModified);
|
||||
}
|
||||
Promise.all(waitOn).then(() => {
|
||||
this.commonObjs.clear();
|
||||
this.fontLoader.clear();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue