From c6362cd55c53b7990fce5ca6dc532f6d855ea690 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Wed, 18 Aug 2021 13:35:36 +0200 Subject: [PATCH] wasm: add Emscripten module accessor to qtloader.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After enabling -s MODULARIZE=1 there is no longer a global MODULE object. Add module() accessor which can be used to retrieve the Emscripten module. This does not really fit with the current state tracking since the app transitions from “loading” to “running” before the module object is ready. We’ll have to revisit this at some point. Change-Id: Ib7191cf4ce436e1de99f84b63ed4c10936fa62b1 Reviewed-by: Lorn Potter --- src/plugins/platforms/wasm/qtloader.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/plugins/platforms/wasm/qtloader.js b/src/plugins/platforms/wasm/qtloader.js index 3a8b7d7f5ca..d73fe3e23af 100644 --- a/src/plugins/platforms/wasm/qtloader.js +++ b/src/plugins/platforms/wasm/qtloader.js @@ -126,6 +126,11 @@ // Signals to the application that a canvas has been resized. // setFontDpi // Sets the logical font dpi for the application. +// module +// Returns the Emscripten module object, or undefined if the module +// has not been created yet. Note that the module object becomes available +// at the very end of the loading sequence, _after_ the transition from +// Loading to Running occurs. function QtLoader(config) @@ -249,6 +254,7 @@ function QtLoader(config) publicAPI.resizeCanvasElement = resizeCanvasElement; publicAPI.setFontDpi = setFontDpi; publicAPI.fontDpi = fontDpi; + publicAPI.module = module; self.restartCount = 0; @@ -586,6 +592,10 @@ function QtLoader(config) return self.qtFontDpi; } + function module() { + return self.module; + } + setStatus("Created"); return publicAPI;