Skip to content
Snippets Groups Projects
Commit ddeef631 authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlDesigner.propertyEditor: bugfix for assert

Since the linedit in the property editor has an input mask,
propery names like "red" are not handled correctly.

Change-Id: I43ec2f7e42de7f57d78c97b6865ea36c4e11b3fb
Solution: We normalize "red" to "#ff0000" in the property editor.
Task-number: QTCREATORBUG-5479
Reviewed-on: http://codereview.qt.nokia.com/1749


Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarMarco Bubke <marco.bubke@nokia.com>
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@nokia.com>
parent 72ca2a7a
No related branches found
No related tags found
No related merge requests found
......@@ -96,6 +96,22 @@ static bool cleverColorCompare(QVariant value1, QVariant value2)
return false;
}
/* "red" is the same color as "#ff0000"
To simplify editing we convert all explicit color names in the hash format */
static void fixAmbigousColorNames(const QmlDesigner::ModelNode &modelNode, const QString &name, QVariant *value)
{
if (modelNode.isValid() && modelNode.metaInfo().isValid()
&& (modelNode.metaInfo().propertyTypeName(name) == "QColor"
|| modelNode.metaInfo().propertyTypeName(name) == "color")) {
if ((value->type() == QVariant::Color)) {
*value = QColor(value->value<QColor>().name());
} else {
*value = QColor(value->toString()).name();
}
}
}
void PropertyEditorValue::setValueWithEmit(const QVariant &value)
{
if (m_value != value || isBound()) {
......@@ -125,6 +141,8 @@ void PropertyEditorValue::setValue(const QVariant &value)
m_value = value;
fixAmbigousColorNames(modelNode(), name(), &m_value);
if (m_value.isValid())
emit valueChangedQml();
emit isBoundChanged();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment