aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlcomponent.cpp
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2021-04-27 14:56:35 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2021-04-27 15:21:44 +0200
commit7275328b967582010abfd59c9a93feef4cb1379f (patch)
tree7e52aec01bd9ec52a33074df6c587544e16ca7ae /src/qml/qml/qqmlcomponent.cpp
parent4f0622f7f553cd841874f0efe65d7f13edeec216 (diff)
QQmlComponentPrivate::setInitialProperty: improve error message
We can discern between the case where the property does not exist at all, and the case where we cannot set it. Pick-to: 6.0 6.1 5.15 Change-Id: Ia2e8f4cc077a00b90d720db01bff1542a812dea0 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlcomponent.cpp')
-rw-r--r--src/qml/qml/qqmlcomponent.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp
index fdd5f0e194..64698444ff 100644
--- a/src/qml/qml/qqmlcomponent.cpp
+++ b/src/qml/qml/qqmlcomponent.cpp
@@ -378,10 +378,15 @@ bool QQmlComponentPrivate::setInitialProperty(QObject *component, const QString&
{
QQmlProperty prop = QQmlComponentPrivate::removePropertyFromRequired(component, name, requiredProperties());
QQmlPropertyPrivate *privProp = QQmlPropertyPrivate::get(prop);
- if (!prop.isValid() || !privProp->writeValueProperty(value, {})) {
+ const bool isValid = prop.isValid();
+ if (!isValid || !privProp->writeValueProperty(value, {})) {
QQmlError error{};
error.setUrl(url);
- error.setDescription(QLatin1String("Could not set property %1").arg(name));
+ if (isValid)
+ error.setDescription(QLatin1String("Could not set initial property %1").arg(name));
+ else
+ error.setDescription(QLatin1String("Setting initial properties failed: %2 does not have a property called %1").arg(name,
+ QQmlMetaType::prettyTypeName(component)));
state.errors.push_back(error);
return false;
} else