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
This commit is contained in:
Kai Koehne
2010-03-30 11:16:25 +02:00
parent b3ad65d89b
commit b5262c9b30

View File

@@ -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;