Don't register a pending TextLayer until render is invoked (PR 18104 follow-up)
After the re-factoring in PR 18104 there's now a *theoretical* risk that a pending `TextLayer` is never removed, which we can avoid by not registering it until `render` is invoked. Note that this doesn't affect the viewer or tests, but if a third-party user calls `new TextLayer(...)` without a following call of either the `render`- or `cancel`-method we'd block global clean-up without this patch.
This commit is contained in:
parent
17e09e5478
commit
f2e7eee00e
@ -122,7 +122,6 @@ class TextLayer {
|
|||||||
|
|
||||||
setLayerDimensions(container, viewport);
|
setLayerDimensions(container, viewport);
|
||||||
|
|
||||||
TextLayer.#pendingTextLayers.add(this);
|
|
||||||
// Always clean-up the temporary canvas once rendering is no longer pending.
|
// Always clean-up the temporary canvas once rendering is no longer pending.
|
||||||
this.#capability.promise
|
this.#capability.promise
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
@ -167,6 +166,7 @@ class TextLayer {
|
|||||||
}, this.#capability.reject);
|
}, this.#capability.reject);
|
||||||
};
|
};
|
||||||
this.#reader = this.#textContentSource.getReader();
|
this.#reader = this.#textContentSource.getReader();
|
||||||
|
TextLayer.#pendingTextLayers.add(this);
|
||||||
pump();
|
pump();
|
||||||
|
|
||||||
return this.#capability.promise;
|
return this.#capability.promise;
|
||||||
@ -423,6 +423,7 @@ class TextLayer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.#ascentCache.clear();
|
this.#ascentCache.clear();
|
||||||
|
|
||||||
for (const { canvas } of this.#canvasContexts.values()) {
|
for (const { canvas } of this.#canvasContexts.values()) {
|
||||||
canvas.remove();
|
canvas.remove();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user