diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2021-03-12 15:46:29 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2021-03-17 13:10:22 +0100 |
commit | 9caea013ceb221b5617c4940e7bb9ee9fecdd631 (patch) | |
tree | f4480e860a965f6515e516475baeced69b5d91fd /src/qml/jsruntime/qv4jsonobject.cpp | |
parent | b0e9c83f99aa7090c82b7c55894f5e264b74608a (diff) |
Clean up JSCallData setup
We either have pre-populated arguments and thisObject, then we can just
use them and keep them const. Or, we want to allocate and populate the
arguments and the thisObject. Then, do allocate them in a separate
object, and transform that into JSCallData afterwards if necessary.
Furthermore, avoid alloc(0) as that just returns the current stack top.
Writing to it will clobber other data. Rather, just use nullptr and
crash if it's written to.
Also, remove the useless operator-> from JSCallData. That one just
confuses the reader.
Change-Id: I8310911fcfe005b05a07b78fcb3791d991a0c2ce
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4jsonobject.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4jsonobject.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp index c580fd2bf5..a3ffdb5431 100644 --- a/src/qml/jsruntime/qv4jsonobject.cpp +++ b/src/qml/jsruntime/qv4jsonobject.cpp @@ -700,9 +700,9 @@ QString Stringify::Str(const QString &key, const Value &v) ScopedString s(scope, v4->newString(QStringLiteral("toJSON"))); ScopedFunctionObject toJSON(scope, o->get(s)); if (!!toJSON) { - JSCallData jsCallData(scope, 1); - *jsCallData->thisObject = value; - jsCallData->args[0] = v4->newString(key); + JSCallArguments jsCallData(scope, 1); + *jsCallData.thisObject = value; + jsCallData.args[0] = v4->newString(key); value = toJSON->call(jsCallData); if (v4->hasException) return QString(); @@ -712,10 +712,10 @@ QString Stringify::Str(const QString &key, const Value &v) if (replacerFunction) { ScopedObject holder(scope, v4->newObject()); holder->put(scope.engine->id_empty(), value); - JSCallData jsCallData(scope, 2); - jsCallData->args[0] = v4->newString(key); - jsCallData->args[1] = value; - *jsCallData->thisObject = holder; + JSCallArguments jsCallData(scope, 2); + jsCallData.args[0] = v4->newString(key); + jsCallData.args[1] = value; + *jsCallData.thisObject = holder; value = replacerFunction->call(jsCallData); if (v4->hasException) return QString(); |