From b5262c9b30d1f237553e79f0c34864d7ff114df3 Mon Sep 17 00:00:00 2001
From: Kai Koehne <kai.koehne@nokia.com>
Date: Tue, 30 Mar 2010 11:16:25 +0200
Subject: [PATCH] QmlDesigner: Fix crash when changing the transform origin of
 an item

Fixes crash when changing the transform origin of an item in the
Property Editor. The fundamental problem is that the metatype system
doesn't know about the enum. We used to return then an invalid QVariant
when trying to convert the string to a QVariant. Now we instead return
a valid QVariant, but with wrong type (QString).

Task-number: BAUHAUS-522
Reviewed-by: Erik Verbruggen
---
 src/plugins/qmldesigner/core/model/propertyparser.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/plugins/qmldesigner/core/model/propertyparser.cpp b/src/plugins/qmldesigner/core/model/propertyparser.cpp
index ded2b374cc5..4043e81827a 100644
--- a/src/plugins/qmldesigner/core/model/propertyparser.cpp
+++ b/src/plugins/qmldesigner/core/model/propertyparser.cpp
@@ -63,10 +63,13 @@ QVariant read(const QString &typeStr, const QString &str, const MetaInfo &metaIn
 QVariant read(const QString &typeStr, const QString &str)
 {
     int type = QMetaType::type(typeStr.toAscii().constData());
-    if (type == 0)
+    if (type == 0) {
         qWarning() << "Type " << typeStr
                 << " is unknown to QMetaType system. Cannot create properly typed QVariant for value "
                 << str;
+        // Fall back to a QVariant of type String
+        return QVariant(str);
+    }
     return read(type, str);
 }
 
@@ -108,9 +111,9 @@ QVariant read(int variantType, const QString &str)
     }
 
     if (!conversionOk) {
-        value = QVariant();
         qWarning() << "Could not convert" << str
                    << "to" << QMetaType::typeName(variantType);
+        value = QVariant(str);
     }
 
     return value;
-- 
GitLab