From fccd9b2aba72d4a1d5ef8aab7963a7633167ac80 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Morten=20S=C3=B8rvig?= <morten.sorvig@qt.io>
Date: Fri, 5 Apr 2024 12:51:22 +0200
Subject: [PATCH] Port examples to Qt 6.7

The Emscripten entry function name is now unique based
on the application name ("$APPNAME_entry"), and must be
specified when creating the wasm instance.

Also some drive-by fixes.
---
 examples/background_loading/index.html      | 8 ++++++--
 examples/javascript_interop/index.html      | 6 +++++-
 examples/multiple_instances/index.html      | 6 +++---
 examples/multiple_windows/index.html        | 6 +++++-
 examples/multiple_windows_simple/index.html | 1 +
 examples/popup_window/index.html            | 6 +++++-
 6 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/examples/background_loading/index.html b/examples/background_loading/index.html
index 56ed25a..c6cdd84 100644
--- a/examples/background_loading/index.html
+++ b/examples/background_loading/index.html
@@ -4,6 +4,7 @@
     <meta charset="utf-8">
     <title>Qt Background Loading</title>
     <script src="../testapp/testapp.js"></script>
+    <script src="../testapp/qtloader.js"></script>
 
     <script>
         window.addEventListener('load', async () => {
@@ -14,8 +15,11 @@
             // config object containing standard Emscripten configuration options.
             // In addtion, Qt app instances reads a couple of options like "qtContainerElements"
             // at startup.
-            let instance = await createQtAppInstance({
-                "qtContainerElements": [container]
+            let instance = await qtLoad({
+                qt: {
+                    containerElements: [container],
+                    entryFunction: testapp_entry
+                }
             });
 
             // At this point the Qt instance has been created; update the
diff --git a/examples/javascript_interop/index.html b/examples/javascript_interop/index.html
index cad532c..fa80cc0 100644
--- a/examples/javascript_interop/index.html
+++ b/examples/javascript_interop/index.html
@@ -18,7 +18,11 @@
         window.data = new Uint8Array([1, 2, 3 ,4]);
 
         window.addEventListener('load', async () => {
-            const instance = await qtLoad({qt:{}});
+            const instance = await qtLoad({
+                qt: {
+                    entryFunction: testapp_entry
+                }
+            });
 
             // enable the "Call C++" button which calls the function exported from jsinterop.cpp.
             const callCppButton = document.getElementById("callcpp");
diff --git a/examples/multiple_instances/index.html b/examples/multiple_instances/index.html
index 02c3e33..7eef8ca 100644
--- a/examples/multiple_instances/index.html
+++ b/examples/multiple_instances/index.html
@@ -23,8 +23,8 @@
             const instance = await qtLoad({
                 qt: {
                     containerElements: [container],
-                    modulePromise: module,
-                    module: module, // ### decide on which one
+                    module: module,
+                    entryFunction: testapp_entry
                 }
             });
             container.style.visibility = "visible";
@@ -47,7 +47,7 @@
     <p>The application windows will appear below, when loaded.</p>
 
     <div id="appcontainer1" style="width:320px; height:200px; visibility:hidden"></div>
-    <p>Window below not showing? Upgrade to Qt >= 6.5.</p >
+    <br>
     <div id="appcontainer2" style="width:320px; height:200px; visibility:hidden"></div>
   </body>
 </html>
\ No newline at end of file
diff --git a/examples/multiple_windows/index.html b/examples/multiple_windows/index.html
index f78f442..81d9b44 100644
--- a/examples/multiple_windows/index.html
+++ b/examples/multiple_windows/index.html
@@ -18,7 +18,11 @@
         {
             // Create test app instance via the default window.createQtAppInstance entry function
             // set by testapp.js
-            const instance = await qtLoad({});
+            const instance = await qtLoad({
+                qt: {
+                    entryFunction: testapp_entry
+                }
+            });
 
             // The Qt instance has been created; enable ui.
             let addWindow = document.getElementById("create-window-button");
diff --git a/examples/multiple_windows_simple/index.html b/examples/multiple_windows_simple/index.html
index 7e31b3d..d8f2802 100644
--- a/examples/multiple_windows_simple/index.html
+++ b/examples/multiple_windows_simple/index.html
@@ -13,6 +13,7 @@
             const instance = await qtLoad({
                 qt: {
                     containerElements: containers,
+                    entryFunction: testapp_entry
                 }
             });
         });
diff --git a/examples/popup_window/index.html b/examples/popup_window/index.html
index 9897ec4..33283e5 100644
--- a/examples/popup_window/index.html
+++ b/examples/popup_window/index.html
@@ -13,7 +13,11 @@
             // Create Qt application instance. This instance exports openPopup and
             // closePopup, which we call below. See ../testapp/popup.cpp for the
             // implementation.
-            window.instance = await qtLoad({});
+            window.instance = await qtLoad({
+                qt: {
+                    entryFunction: testapp_entry
+                }
+            });
 
             let openPopup = document.getElementById("open-popup");
             openPopup.disabled = false;
-- 
GitLab