Improve the promise-caching in the PDFDocument.fieldObjects getter
After PR 18845 we're accessing this getter more, hence it seems like a good idea to ensure that the initial `formInfo` access is covered as well. While unlikely to be a problem in practice, at least theoretically that data may not be available and the code in `fieldObjects` could thus currently be *unintentionally* invoked more than once.
This commit is contained in:
parent
81cf42df47
commit
e3b5ed2e40
@ -1871,14 +1871,17 @@ class PDFDocument {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get fieldObjects() {
|
get fieldObjects() {
|
||||||
if (!this.formInfo.hasFields) {
|
const promise = this.pdfManager
|
||||||
return shadow(this, "fieldObjects", Promise.resolve(null));
|
.ensureDoc("formInfo")
|
||||||
|
.then(async formInfo => {
|
||||||
|
if (!formInfo.hasFields) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const promise = Promise.all([
|
const [annotationGlobals, acroForm] = await Promise.all([
|
||||||
this.pdfManager.ensureDoc("annotationGlobals"),
|
this.pdfManager.ensureDoc("annotationGlobals"),
|
||||||
this.pdfManager.ensureCatalog("acroForm"),
|
this.pdfManager.ensureCatalog("acroForm"),
|
||||||
]).then(async ([annotationGlobals, acroForm]) => {
|
]);
|
||||||
if (!annotationGlobals) {
|
if (!annotationGlobals) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user