Skip to content

Commit d41f144

Browse files
authored
Merge pull request #20148 from fnlctrl/icc-lazy-finalization-registry
Lazy initialize FinalizationRegistry used by IccColorSpace.#finalizer
2 parents e9a4830 + 3d9374e commit d41f144

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/core/icc_colorspace.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ class IccColorSpace extends ColorSpace {
4848

4949
static #wasmUrl = null;
5050

51-
static #finalizer = new FinalizationRegistry(transformer => {
52-
qcms_drop_transformer(transformer);
53-
});
51+
static #finalizer = null;
5452

5553
constructor(iccProfile, name, numComps) {
5654
if (!IccColorSpace.isUsable) {
@@ -100,6 +98,9 @@ class IccColorSpace extends ColorSpace {
10098
if (!this.#transformer) {
10199
throw new Error("Failed to create ICC color space");
102100
}
101+
IccColorSpace.#finalizer ||= new FinalizationRegistry(transformer => {
102+
qcms_drop_transformer(transformer);
103+
});
103104
IccColorSpace.#finalizer.register(this, this.#transformer);
104105
}
105106

0 commit comments

Comments
 (0)