aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlmetatype_p.h
diff options
context:
space:
mode:
authorAndrei Golubev <andrei.golubev@qt.io>2022-05-02 14:24:55 +0200
committerAndrei Golubev <andrei.golubev@qt.io>2022-05-04 22:34:15 +0200
commit218eb5f5712dd920459cb0108fcd305d653352bc (patch)
tree34798f00d69bb5458b62813a7808400d9fbb0115 /src/qml/qml/qqmlmetatype_p.h
parent57f025ee83728ae5debb9e71649e2bd80614f39f (diff)
QQmlProxyMetaObject: Ignore properties/methods of non-creatable proxies
Qt/QML allows marking a type with QML_EXTENDED_NAMESPACE(Type) where Type is a Q_OBJECT. In this case, we have a Type-specific meta object but do not have an extension function to create the object of that Type with, causing us a subtle runtime crash. The crash in fact happens when we attempt to access a shadowed property through the extension object (which surely fails since there's no extension object) Fix this by excluding properties and methods when cloning the metaobject for the proxy if we know that the proxy cannot be created. This somewhat matches what the documentation says about QML_EXTENDED_NAMESPACE: When we have a Q_OBJECT/Q_GADGET, methods and properties of that are not exposed As a drive by, add the same check to the QQmlMetaType::proxyData(). While untested, this seems logical since the proxy data assumes valid creation function in this case as well Fixes: QTBUG-103081 Change-Id: I63c6e535d4df5169e0279eb2f588593f43a70640 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlmetatype_p.h')
-rw-r--r--src/qml/qml/qqmlmetatype_p.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/qml/qml/qqmlmetatype_p.h b/src/qml/qml/qqmlmetatype_p.h
index 31ceb8d7f8..2c010f516d 100644
--- a/src/qml/qml/qqmlmetatype_p.h
+++ b/src/qml/qml/qqmlmetatype_p.h
@@ -258,8 +258,13 @@ public:
const QMetaObject *baseMetaObject,
QMetaObject *lastMetaObject);
+ enum ClonePolicy {
+ CloneAll, // default
+ CloneEnumsOnly, // skip properties and methods
+ };
static void clone(QMetaObjectBuilder &builder, const QMetaObject *mo,
- const QMetaObject *ignoreStart, const QMetaObject *ignoreEnd);
+ const QMetaObject *ignoreStart, const QMetaObject *ignoreEnd,
+ ClonePolicy policy);
static void qmlInsertModuleRegistration(const QString &uri, void (*registerFunction)());
static void qmlRemoveModuleRegistration(const QString &uri);