aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4engine.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2022-09-01 16:14:30 +0200
committerUlf Hermann <ulf.hermann@qt.io>2022-09-07 16:57:16 +0200
commitd3b3fef5a878d7fd53de6a9f9fff196a273930e3 (patch)
tree76b96ff3d6f34a01bf4a9881dd75626921c49daf /src/qml/jsruntime/qv4engine.cpp
parent5cda89ce030ff5fbc9e95be1b9ca74adb401a9d7 (diff)
Qml: Allow const and non-const QObjectWrappers to coexist
We can access the same QObject in const and non-const contexts. Both should be possible. Store the const objectwrapper in m_multiplyWrappedObjects. That's somewhat slow, but const QObjects are rather rare. Pick-to: 6.4 Fixes: QTBUG-98479 Change-Id: I047afc121f5c29b955cd833e0a2c8299fc52b021 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4engine.cpp')
-rw-r--r--src/qml/jsruntime/qv4engine.cpp14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index 06ba98aad2..26677a37b9 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -1855,16 +1855,10 @@ QV4::ReturnedValue ExecutionEngine::fromData(
a->setArrayLengthUnchecked(list.count());
return a.asReturnedValue();
} else if (auto flags = metaType.flags(); flags & QMetaType::PointerToQObject) {
- QV4::ReturnedValue ret = QV4::QObjectWrapper::wrap(this, *reinterpret_cast<QObject* const *>(ptr));
- if (!flags.testFlag(QMetaType::IsConst))
- return ret;
- QV4::ScopedValue v(scope, ret);
- if (auto obj = v->as<Object>()) {
- obj->setInternalClass(obj->internalClass()->cryopreserved());
- return obj->asReturnedValue();
- } else {
- return ret;
- }
+ if (flags.testFlag(QMetaType::IsConst))
+ return QV4::QObjectWrapper::wrapConst(this, *reinterpret_cast<QObject* const *>(ptr));
+ else
+ return QV4::QObjectWrapper::wrap(this, *reinterpret_cast<QObject* const *>(ptr));
}
bool succeeded = false;