summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEven Oscar Andersen <even.oscar.andersen@qt.io>2025-11-21 06:08:16 +0100
committerMorten Johan Sørvig <morten.sorvig@qt.io>2025-11-25 18:46:05 +0000
commit9f8f49cc140a9d1f90f2dd4b96def69a435c4080 (patch)
treeb7f474009d101f86c234b5fae7b010abd4ccd32e /src
parent2f465fbe636d40f028a566e0a704f20aedde267c (diff)
wasm: Do not clone non Event objects
The problem is (at least) with ArrayBuffer. It cannot be accessed as a list of key/value pairs. It turns out we only need to (partially) clone Event objects, so limit the logic to do just that. Change-Id: I9796250ad63266d38e760ce84a4f2150a74f337e Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/platform/wasm/qwasmsuspendresumecontrol.cpp30
1 files changed, 9 insertions, 21 deletions
diff --git a/src/corelib/platform/wasm/qwasmsuspendresumecontrol.cpp b/src/corelib/platform/wasm/qwasmsuspendresumecontrol.cpp
index a081edcf542..5fe92926240 100644
--- a/src/corelib/platform/wasm/qwasmsuspendresumecontrol.cpp
+++ b/src/corelib/platform/wasm/qwasmsuspendresumecontrol.cpp
@@ -77,32 +77,20 @@ void qtRegisterEventHandlerJs(int index) {
}[name];
}
- function deepShallowClone(parent, obj, depth) {
+ function deepShallowClone(obj) {
if (obj === null)
return obj;
- if (typeof obj === 'function') {
- if (obj.name !== "")
- return createNamedFunction(obj.name, parent, obj);
- }
-
- if (depth >= 1)
- return obj;
-
- if (typeof obj !== 'object')
+ if (!(obj instanceof Event))
return obj;
- if (Array.isArray(obj)) {
- const arrCopy = [];
- for (let i = 0; i < obj.length; i++)
- arrCopy[i] = deepShallowClone(obj, obj[i], depth + 1);
-
- return arrCopy;
- }
-
const objCopy = {};
- for (const key in obj)
- objCopy[key] = deepShallowClone(obj, obj[key], depth + 1);
+ for (const key in obj) {
+ if (typeof obj[key] === 'function')
+ objCopy[key] = createNamedFunction(obj[key].name, obj, obj[key]);
+ else
+ objCopy[key] = obj[key];
+ }
return objCopy;
}
@@ -112,7 +100,7 @@ void qtRegisterEventHandlerJs(int index) {
let handler = (arg) => {
// Copy the top level object, alias the rest.
// functions are copied by creating new forwarding functions.
- arg = deepShallowClone(arg, arg, 0);
+ arg = deepShallowClone(arg);
// Add event to event queue
control.pendingEvents.push({