Check that the correct pdfDocument
is still active, before rendering the outline/attachments/layers
*This patch fixes some technical debt in the viewer.* Given that most API methods are (purposely) asynchronous, there's always a risk that the viewer could have been `close`d before the requested data arrives. Lately we've started to check this case before using the data, to prevent errors and/or inconsistent state, however the outline/attachments/layers fetching and rendering is old enough that it pre-dates those checks.
This commit is contained in:
parent
f5e973d555
commit
05b0798824
@ -1383,14 +1383,23 @@ const PDFViewerApplication = {
|
||||
|
||||
onePageRendered.then(() => {
|
||||
pdfDocument.getOutline().then(outline => {
|
||||
if (pdfDocument !== this.pdfDocument) {
|
||||
return; // The document was closed while the outline resolved.
|
||||
}
|
||||
this.pdfOutlineViewer.render({ outline, pdfDocument });
|
||||
});
|
||||
pdfDocument.getAttachments().then(attachments => {
|
||||
if (pdfDocument !== this.pdfDocument) {
|
||||
return; // The document was closed while the attachments resolved.
|
||||
}
|
||||
this.pdfAttachmentViewer.render({ attachments });
|
||||
});
|
||||
// Ensure that the layers accurately reflects the current state in the
|
||||
// viewer itself, rather than the default state provided by the API.
|
||||
pdfViewer.optionalContentConfigPromise.then(optionalContentConfig => {
|
||||
if (pdfDocument !== this.pdfDocument) {
|
||||
return; // The document was closed while the layers resolved.
|
||||
}
|
||||
this.pdfLayerViewer.render({ optionalContentConfig, pdfDocument });
|
||||
});
|
||||
if (
|
||||
|
Loading…
Reference in New Issue
Block a user