Skip to content

Commit

Permalink
Allow aliases to QVariant properties
Browse files Browse the repository at this point in the history
Task-number: QTBUG-22464
Change-Id: I449d4fc709d34a69116258660d721596cd9b778b
Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
  • Loading branch information
Aaron Kennedy authored and Qt by Nokia committed Nov 16, 2011
1 parent e443db4 commit cb26606
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/declarative/qml/qdeclarativecompiler.cpp
Expand Up @@ -3112,7 +3112,8 @@ bool QDeclarativeCompiler::compileAlias(QFastMetaBuilder &builder,
writable = aliasProperty.isWritable() && !prop.isReadOnly;
resettable = aliasProperty.isResettable() && !prop.isReadOnly;

if (aliasProperty.type() < QVariant::UserType)
if (aliasProperty.type() < QVariant::UserType ||
aliasProperty.type() == QVariant::LastType /* for QVariant */ )
type = aliasProperty.type();

if (alias.count() == 3) {
Expand Down
15 changes: 15 additions & 0 deletions tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22464.qml
@@ -0,0 +1,15 @@
import QtQuick 2.0

QtObject {
property alias value: inner.value
property bool test: false

property variant dummy: QtObject {
id: inner
property variant value: Qt.rgba(1, 1, 0, 1);
}

Component.onCompleted: {
test = (value == Qt.rgba(1, 1, 0, 1));
}
}
Expand Up @@ -177,7 +177,7 @@ private slots:
void sequenceConversionThreads();
void sequenceConversionBindings();
void sequenceConversionCopy();

void qtbug_22464();
void bug1();
void bug2();
void dynamicCreationCrash();
Expand Down Expand Up @@ -1643,6 +1643,18 @@ void tst_qdeclarativeecmascript::undefinedResetsProperty()
}
}

// Aliases to variant properties should work
void tst_qdeclarativeecmascript::qtbug_22464()
{
QDeclarativeComponent component(&engine, TEST_FILE("qtbug_22464.qml"));
QObject *object = component.create();
QVERIFY(object != 0);

QCOMPARE(object->property("test").toBool(), true);

delete object;
}

// QTBUG-6781
void tst_qdeclarativeecmascript::bug1()
{
Expand Down

0 comments on commit cb26606

Please sign in to comment.