From e75088323ae15604139ddfd66b85cc3b8d43abeb Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 20 May 2010 14:15:48 +1000 Subject: Be consistent in conversion from string (eg. color, int rounding). Task-number: QTBUG-10820 Reviewed-by: Michael Brasser --- src/declarative/qml/qdeclarativeproperty.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/declarative/qml/qdeclarativeproperty.cpp b/src/declarative/qml/qdeclarativeproperty.cpp index 723237a..071dd07 100644 --- a/src/declarative/qml/qdeclarativeproperty.cpp +++ b/src/declarative/qml/qdeclarativeproperty.cpp @@ -1050,18 +1050,21 @@ bool QDeclarativePropertyPrivate::write(QObject *object, const QDeclarativePrope Q_ASSERT(variantType != propertyType); bool ok = false; - QVariant v = value; - if (v.convert((QVariant::Type)propertyType)) { - ok = true; - } else if ((uint)propertyType >= QVariant::UserType && variantType == QVariant::String) { - QDeclarativeMetaType::StringConverter con = QDeclarativeMetaType::customStringConverter(propertyType); - if (con) { - v = con(value.toString()); - if (v.userType() == propertyType) - ok = true; - } - } else if (variantType == QVariant::String) { + QVariant v; + if (variantType == QVariant::String) v = QDeclarativeStringConverters::variantFromString(value.toString(), propertyType, &ok); + if (!ok) { + v = value; + if (v.convert((QVariant::Type)propertyType)) { + ok = true; + } else if ((uint)propertyType >= QVariant::UserType && variantType == QVariant::String) { + QDeclarativeMetaType::StringConverter con = QDeclarativeMetaType::customStringConverter(propertyType); + if (con) { + v = con(value.toString()); + if (v.userType() == propertyType) + ok = true; + } + } } if (ok) { void *a[] = { (void *)v.constData(), 0, &status, &flags}; -- cgit v0.12