From f2e3d6c81919fed88423220174deb588f12cd710 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sat, 22 Aug 2020 17:37:26 +0200 Subject: [PATCH 1/3] Don't warn when navigating away from a modified form, if printing has occurred (issue 12262) This solution is obviously *not* perfect, since printing being cancelled will thus remove the warning as well. However, a similar problem already exists for saving, since the user may cancel that one as well. All-in-all, since way cannot really detect with absolute certainty that either saving or printing actually finished, this seems good enough for now. --- web/app.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/web/app.js b/web/app.js index 949d1c4ad..9bbe26deb 100644 --- a/web/app.js +++ b/web/app.js @@ -1687,6 +1687,10 @@ const PDFViewerApplication = { if (this.printService) { this.printService.destroy(); this.printService = null; + + if (this.pdfDocument) { + this.pdfDocument.annotationStorage.resetModified(); + } } this.forceRendering(); }, From 1f5021d76ac12f44e378ceac72b6333772e4edab Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sat, 22 Aug 2020 18:09:17 +0200 Subject: [PATCH 2/3] Prevent errors if `PDFDocumentProxy.saveDocument` is called without the `annotationStorage` parameter (PR 12241 follow-up) Obviously it doesn't make sense to call that method without providing an `AnnotationStorage`-instance, however we should ensure that doing so won't cause errors. Hence we need to check that `annotationStorage` is actually defined, before attempting to call its `resetModified` method. --- src/display/api.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/display/api.js b/src/display/api.js index 453e073a5..f9a295dcc 100644 --- a/src/display/api.js +++ b/src/display/api.js @@ -2544,7 +2544,9 @@ class WorkerTransport { filename: this._fullReader ? this._fullReader.filename : null, }) .finally(() => { - annotationStorage.resetModified(); + if (annotationStorage) { + annotationStorage.resetModified(); + } }); } From fa02808f765030a47d2c6f3e41dcf3102b6c00ae Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sat, 22 Aug 2020 20:04:25 +0200 Subject: [PATCH 3/3] Mark the `setModified` method, on `AnnotationStorage`, as "private" (PR 12241 follow-up) Since it shouldn't be called manually, we can just mark it as "private". --- src/display/annotation_storage.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/display/annotation_storage.js b/src/display/annotation_storage.js index 96e730223..e1b4fac3a 100644 --- a/src/display/annotation_storage.js +++ b/src/display/annotation_storage.js @@ -58,7 +58,7 @@ class AnnotationStorage { */ setValue(key, value) { if (this._storage.get(key) !== value) { - this.setModified(); + this._setModified(); } this._storage.set(key, value); } @@ -74,7 +74,10 @@ class AnnotationStorage { return this._storage.size; } - setModified() { + /** + * @private + */ + _setModified() { if (!this._modified) { this._modified = true; if (typeof this.onSetModified === "function") {