aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlproperty.cpp
diff options
context:
space:
mode:
authorChristian Strømme <christian.stromme@qt.io>2016-06-02 12:08:29 +0200
committerChristian Stromme <christian.stromme@qt.io>2016-08-09 11:24:19 +0000
commit35597f301480ffc59f598be4de2c2074543725be (patch)
tree8c22a97c583b1c2c5b88663e442f24486a33e921 /src/qml/qml/qqmlproperty.cpp
parent31ca52cee47f189ee1c80245f7b114c29ac7c675 (diff)
Fix char conversions in QML
This is a partial revert of 90b06e2773842, as it had unwanted side effects. The original intention was to make assignment from char to string possible, or more specifically, we wanted a solution where a QChar could be assigned to a QString, as a character and not a string representation of its value. While this behavior is desirable for QChar, we most likely want the opposite for the regular character types. Task-number: QTBUG-49232 Change-Id: I82d5f72b900fe984c4db1478fd52a9eb69ad2ee6 Reviewed-by: Michael Brasser <michael.brasser@live.com> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlproperty.cpp')
-rw-r--r--src/qml/qml/qqmlproperty.cpp25
1 files changed, 2 insertions, 23 deletions
diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp
index 1b78ada698..1eaff6b600 100644
--- a/src/qml/qml/qqmlproperty.cpp
+++ b/src/qml/qml/qqmlproperty.cpp
@@ -1327,29 +1327,8 @@ bool QQmlPropertyPrivate::write(QObject *object,
bool ok = false;
QVariant v;
- if (variantType == QVariant::String) {
- const QString &str = value.toString();
- const bool targetIsChar = (propertyType == qMetaTypeId<QChar>()
- || propertyType == qMetaTypeId<char>()
- || propertyType == qMetaTypeId<unsigned char>());
- // If the string contains only one character and the target is a char, try converting it.
- if (targetIsChar) {
- if (str.size() != 1)
- return false; // We can only convert if the string contains exactly one character.
-
- const QChar &qChar = str.at(0);
- if (propertyType == qMetaTypeId<QChar>()) {
- v = qChar;
- ok = true;
- } else if (propertyType == qMetaTypeId<char>() || propertyType == qMetaTypeId<unsigned char>()) {
- const char c = qChar.toLatin1();
- v = c;
- ok = (qChar == c);
- }
- } else {
- v = QQmlStringConverters::variantFromString(str, propertyType, &ok);
- }
- }
+ if (variantType == QVariant::String)
+ v = QQmlStringConverters::variantFromString(value.toString(), propertyType, &ok);
if (!ok) {
v = value;