diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2023-01-16 15:00:46 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2023-01-23 22:27:38 +0100 |
commit | 6bdeafcad69aeb6b615129c1a3399e4c2bce2d28 (patch) | |
tree | b7c729cabe0a81f4722e42d5ec880981642e2407 /src/qml/qml/qqml.cpp | |
parent | a6d6b1832df22d57c5de98a5abfee20cd86f729b (diff) |
QML: Output a warning for creatable object types without default ctor
Pick-to: 6.5
Fixes: QTBUG-104899
Change-Id: I237ddb68968b26c1ce41051ab3bd3c66fb1712f1
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/qml/qml/qqml.cpp')
-rw-r--r-- | src/qml/qml/qqml.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/qml/qml/qqml.cpp b/src/qml/qml/qqml.cpp index 73eff6f3fc..07aea5e553 100644 --- a/src/qml/qml/qqml.cpp +++ b/src/qml/qml/qqml.cpp @@ -141,6 +141,31 @@ QObject *QQmlPrivate::qmlExtendedObject(QObject *object, int index) return static_cast<QObject *>(result); } +void QQmlPrivate::qmlRegistrationWarning( + QQmlPrivate::QmlRegistrationWarning warning, QMetaType metaType) +{ + switch (warning) { + case UnconstructibleType: + qWarning() + << metaType.name() + << "is neither a QObject, nor default- and copy-constructible, nor uncreatable." + << "You should not use it as a QML type."; + break; + case UnconstructibleSingleton: + qWarning() + << "Singleton" << metaType.name() + << "needs either a default constructor or, when adding a default" + << "constructor is infeasible, a public static" + << "create(QQmlEngine *, QJSEngine *) method."; + break; + case NonQObjectWithAtached: + qWarning() + << metaType.name() + << "is not a QObject, but has attached properties. This won't work."; + break; + } +} + int qmlRegisterUncreatableMetaObject(const QMetaObject &staticMetaObject, const char *uri, int versionMajor, int versionMinor, const char *qmlName, |