Clarify error message for QML type registration

Fixes: QTBUG-114966
Change-Id: I3451cf38841cbefe0fa8d7c07ce91da372f8d184
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
Amanda Hamblin-Trué 2023-06-29 17:05:30 +02:00
parent b9bfdea0e2
commit 6ea6bbeb32
3 changed files with 11 additions and 8 deletions

View File

@ -151,9 +151,10 @@ void QQmlPrivate::qmlRegistrationWarning(
{
switch (warning) {
case UnconstructibleType:
qWarning()
qWarning().nospace()
<< metaType.name()
<< "is neither a QObject, nor default- and copy-constructible, nor uncreatable."
<< " is neither a default constructible QObject, nor a default- "
<< "and copy-constructible Q_GADGET, nor marked as uncreatable.\n"
<< "You should not use it as a QML type.";
break;
case UnconstructibleSingleton:

View File

@ -826,8 +826,8 @@ struct QmlTypeAndRevisionsRegistration<T, Resolved, Extended, false, false, fals
}
#else
static_assert(QQmlPrivate::QmlMetaType<Resolved>::hasAcceptableCtors(),
"This type is neither a QObject, nor default- and copy-constructible, nor"
"uncreatable.\n"
"This type is neither a default constructible QObject, nor a default- "
"and copy-constructible Q_GADGET, nor marked as uncreatable.\n"
"You should not use it as a QML type.");
static_assert(std::is_base_of_v<QObject, Resolved>
|| !QQmlTypeInfo<Resolved>::hasAttachedProperties);

View File

@ -536,13 +536,15 @@ void tst_qmltyperegistrar::uncreatable()
#if QT_DEPRECATED_SINCE(6, 4)
QTest::ignoreMessage(
QtWarningMsg,
"BadUncreatable is neither a QObject, nor default- and copy-constructible, "
"nor uncreatable. You should not use it as a QML type.");
"BadUncreatable is neither a default constructible QObject, nor a default- "
"and copy-constructible Q_GADGET, nor marked as uncreatable.\n"
"You should not use it as a QML type.");
qmlRegisterTypesAndRevisions<BadUncreatable>("A", 1);
QTest::ignoreMessage(
QtWarningMsg,
"BadUncreatableExtended is neither a QObject, nor default- and copy-constructible, "
"nor uncreatable. You should not use it as a QML type.");
"BadUncreatableExtended is neither a default constructible QObject, nor a default- "
"and copy-constructible Q_GADGET, nor marked as uncreatable.\n"
"You should not use it as a QML type.");
qmlRegisterTypesAndRevisions<BadUncreatableExtended>("A", 1);
#endif