diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2020-11-12 11:57:36 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2020-11-12 12:58:09 +0100 |
commit | b92d29c9e3d7a38a072be483e3fdd716271565c2 (patch) | |
tree | dd49d9f82188ea9b4997bb1661c3541bacd40e61 | |
parent | 88119bd35aa578ca8d2eafb6d2921ac1b7bb2a56 (diff) |
QmlCompiler: Correctly store AOT functions
There always has to be an empty last function. Otherwise we might access
invalid memory when loading them.
Change-Id: I5e7a784c14ac8a12450926b895664a98c03f85f1
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
-rw-r--r-- | src/qmlcompiler/qqmljscompiler.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/qmlcompiler/qqmljscompiler.cpp b/src/qmlcompiler/qqmljscompiler.cpp index 6412f47d38..9c2ea7b68e 100644 --- a/src/qmlcompiler/qqmljscompiler.cpp +++ b/src/qmlcompiler/qqmljscompiler.cpp @@ -448,10 +448,11 @@ bool qSaveQmlJSUnitAsCpp(const QString &inputFileName, const QString &outputFile if (!writeStr("};\n")) return false; - if (aotFunctions.isEmpty()) { + writeStr(aotFunctions[FileScopeCodeIndex].code.toUtf8().constData()); + if (aotFunctions.size() <= 1) { + // FileScopeCodeIndex is always there, but it may be the only one. writeStr("extern const QQmlPrivate::AOTCompiledFunction aotBuiltFunctions[] = { { 0, QMetaType::fromType<void>(), nullptr } };"); } else { - writeStr(aotFunctions[FileScopeCodeIndex].code.toUtf8().constData()); writeStr(R"(template <typename Binding> void wrapCall(QQmlContext *context, QObject *scopeObject, void *dataPtr, Binding &&binding) { using return_type = std::invoke_result_t<Binding, QQmlContext*, QObject*>; @@ -485,6 +486,8 @@ bool qSaveQmlJSUnitAsCpp(const QString &inputFileName, const QString &outputFile .toUtf8().constData()); } + // Conclude the list with a nullptr + writeStr("{ 0, QMetaType::fromType<void>(), nullptr }"); writeStr("};\n"); } |