diff options
author | Mikolaj Boc <mikolaj.boc@qt.io> | 2022-10-31 13:22:52 +0100 |
---|---|---|
committer | Mikolaj Boc <mikolaj.boc@qt.io> | 2022-11-01 09:28:06 +0100 |
commit | 18425c33292b4f11d2bf0b8cdd4e89fe51550f57 (patch) | |
tree | 31acfee4051f3fa39a7cc219f836ff7e48f53f29 /src/plugins/platforms/wasm/qtloader.js | |
parent | f6b1c875d944b0917c332a25449dfdfb571c277b (diff) |
qtLoader: Don't assign properties on random self
The 'const self = this;' declaration was omitted in QtLoader constructor,
which made all of the self.something = value assignments actually
assign to the scope self variable (window.self, in most cases).
Make the loader always be constructed with 'new', and assign 'this' to
'self' to always assign properties to the QtLoader instance.
Change-Id: I9cf7cc95e7341531a702edc431aa242b39911f66
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src/plugins/platforms/wasm/qtloader.js')
-rw-r--r-- | src/plugins/platforms/wasm/qtloader.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/plugins/platforms/wasm/qtloader.js b/src/plugins/platforms/wasm/qtloader.js index 2de0ac95e8..33f27bd9b2 100644 --- a/src/plugins/platforms/wasm/qtloader.js +++ b/src/plugins/platforms/wasm/qtloader.js @@ -109,8 +109,25 @@ // Loading to Running occurs. +// Forces the use of constructor on QtLoader instance. +// This passthrough makes both the old-style: +// +// const loader = QtLoader(config); +// +// and the new-style: +// +// const loader = new QtLoader(config); +// +// styles work. function QtLoader(config) { + return new _QtLoader(config); +} + +function _QtLoader(config) +{ + const self = this; + // The Emscripten module and module configuration object. The module // object is created in completeLoadEmscriptenModule(). self.module = undefined; |