diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-10-01 15:30:53 +0200 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-10-03 17:50:51 +0200 |
commit | 86379e265e19a078545306d93c59b0d92c04920a (patch) | |
tree | 92ba25a0efa74285a3b362b11772462283626af5 /src | |
parent | 5599abf6259998f312289f8c2ae48e5ea54ac2d7 (diff) |
QQmlProperty::write: historical reason does not hold in Qt 6
There was a codepath which checked after a failed QVariant conversion
whether the variant is valid and is null at the same time. In that case,
the conversion would be treated as successful.
The motivation for this can be traced back to QTBUG-37197, and our
handling of strings. However, since those times various things have
changed:
- QVariant::isNull() does not return true anymore if its contained type
is null. Thus the conversion of a QVariant holding a null QString will
not lead to a conversion failure (as long as the target type is
actually a conversion target for a QString).
- A failed conversion will always leave the resulting variant in a state
in which it is valid.
The latter is rather problematic, as we would thus always enter the code
path when the source QVariant happened to be null; even in the case
where the source and target types are really incompatible. This can for
instance be observed in tst_qjsonbinding, where assigning null to a
QJsonArray would suddenly "work", thus leading to a test failure.
However, thanks to the first point, it is safe to completely remove this
code.
Change-Id: I176a5c4b04295d128919cab8a333b8a5a2c2345d
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Simon Hausmann <hausmann@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/qml/qqmlproperty.cpp | 6 |
1 files changed, 0 insertions, 6 deletions
diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp index afdec1d450..a30314635a 100644 --- a/src/qml/qml/qqmlproperty.cpp +++ b/src/qml/qml/qqmlproperty.cpp @@ -1372,12 +1372,6 @@ bool QQmlPropertyPrivate::write( v = value; if (v.convert(QMetaType(propertyType))) { ok = true; - } else if (v.isValid() && value.isNull()) { - // For historical reasons converting a null QVariant to another type will do the trick - // but return false anyway. This is caught with the above condition and considered a - // successful conversion. - Q_ASSERT(v.userType() == propertyType); - ok = true; } else if (static_cast<uint>(propertyType) >= QMetaType::User && variantType == QMetaType::QString) { QQmlMetaType::StringConverter con = QQmlMetaType::customStringConverter(propertyType); |