diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2023-01-03 15:45:31 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2023-01-20 20:39:11 +0100 |
commit | ec58c0ddb7fe1ebf33c80335ab9435e53fd00274 (patch) | |
tree | d30a8779fa5fb82bcc9e3b31e581d3962dc81d21 /src/qml/qml/qqmlirloader.cpp | |
parent | ea5200b82f21e0f4d080d3fc256b218e0ee56f3d (diff) |
QML: Add a pragma for value type behavior
Unfortunately value types behave differently when compiled to C++.
Document the difference and introduce a pragma to make them behave one
way or the other.
Pick-to: 6.5
Fixes: QTBUG-109221
Change-Id: Ib2685153c0b4ae209bafbea7a01229377fdb47dd
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlirloader.cpp')
-rw-r--r-- | src/qml/qml/qqmlirloader.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlirloader.cpp b/src/qml/qml/qqmlirloader.cpp index c80f9b4bd1..5137c4c1ab 100644 --- a/src/qml/qml/qqmlirloader.cpp +++ b/src/qml/qml/qqmlirloader.cpp @@ -55,6 +55,12 @@ void QQmlIRLoader::load() createPragma(type)->nativeMethodBehavior = value; }; + const auto createValueTypePragma = [&]( + Pragma::PragmaType type, + Pragma::ValueTypeBehaviorValue value) { + createPragma(type)->valueTypeBehavior = value; + }; + if (unit->flags & QV4::CompiledData::Unit::IsSingleton) createPragma(Pragma::Singleton); if (unit->flags & QV4::CompiledData::Unit::IsStrict) @@ -74,6 +80,9 @@ void QQmlIRLoader::load() if (unit->flags & QV4::CompiledData::Unit::NativeMethodsAcceptThisObject) createNativeMethodPragma(Pragma::NativeMethodBehavior, Pragma::AcceptThisObject); + if (unit->flags & QV4::CompiledData::Unit::ValueTypesCopied) + createValueTypePragma(Pragma::ValueTypeBehavior, Pragma::Copy); + for (uint i = 0; i < qmlUnit->nObjects; ++i) { const QV4::CompiledData::Object *serializedObject = qmlUnit->objectAt(i); QmlIR::Object *object = loadObject(serializedObject); |