QmlDesigner: Relaxe value property setter

The value.isNull() was misleading. It should only check if a value is
invalid. The null sematics in Qt are special anyway because it they can be
misleading. Most values have no special "null" value like pointers or NaN
with floating point values. QString is for example exposes it's
implementation with a pointer. Sometimes zero is reportet as null but this
not what we wanted to know. So just treat null strings as empty strings.

Change-Id: I6599f6c97f22aff83779a0b32415bf52fd64d82f
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Marco Bubke
2021-04-08 09:12:03 +02:00
parent 3c0d7e9c18
commit 3f0f289b28

View File

@@ -57,8 +57,7 @@ void VariantProperty::setValue(const QVariant &value)
if (isDynamic()) if (isDynamic())
qWarning() << "Calling VariantProperty::setValue on dynamic property."; qWarning() << "Calling VariantProperty::setValue on dynamic property.";
// QVector*D(0, 0, 0) detects as null variant though it is valid value if (!value.isValid())
if (value.isNull() && (value.type() != QVariant::Vector3D && value.type() != QVariant::Vector2D))
throw InvalidArgumentException(__LINE__, __FUNCTION__, __FILE__, name()); throw InvalidArgumentException(__LINE__, __FUNCTION__, __FILE__, name());
if (internalNode()->hasProperty(name())) { //check if oldValue != value if (internalNode()->hasProperty(name())) { //check if oldValue != value