Skip to content

Commit

Permalink
Allow static alias to composite type
Browse files Browse the repository at this point in the history
Task-number: QTBUG-20200

Change-Id: I2a118dfc9ce1956e038f70049c905ec38396fe5e
Reviewed-on: http://codereview.qt.nokia.com/2062
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
  • Loading branch information
Aaron Kennedy authored and Qt by Nokia committed Jul 25, 2011
1 parent 647ea95 commit 5249c88
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 14 deletions.
20 changes: 6 additions & 14 deletions src/declarative/qml/qdeclarativecompiler.cpp
Expand Up @@ -2774,21 +2774,13 @@ bool QDeclarativeCompiler::compileAlias(QMetaObjectBuilder &builder,
else
typeName = aliasProperty.typeName();
} else {
typeName = idObject->metaObject()->className();
Q_ASSERT(idObject->type != -1); // How else did it get an id?

//use the base type since it has been registered with metatype system
int index = typeName.indexOf("_QML_");
if (index != -1) {
typeName = typeName.left(index);
} else {
index = typeName.indexOf("_QMLTYPE_");
const QMetaObject *mo = idObject->metaObject();
while (index != -1 && mo) {
typeName = mo->superClass()->className();
index = typeName.indexOf("_QMLTYPE_");
mo = mo->superClass();
}
}
const QDeclarativeCompiledData::TypeReference &ref = output->types.at(idObject->type);
if (ref.type)
typeName = ref.type->typeName();
else
typeName = ref.component->root->className();

typeName += '*';
}
Expand Down
@@ -0,0 +1,6 @@
import QtQuick 1.0

QtObject {
property alias group: obj
property variant foo: AliasToCompositeElementType2 { id: obj }
}
@@ -0,0 +1,5 @@
import QtQuick 1.0

QtObject {
property int value
}
@@ -0,0 +1,6 @@
import QtQuick 1.0

AliasToCompositeElementType1 {
group.value: 13
}

Expand Up @@ -182,6 +182,7 @@ private slots:
void aliasBindingsAssignCorrectly();
void aliasBindingsOverrideTarget();
void aliasWritesOverrideBindings();
void aliasToCompositeElement();
void realToInt();

void include();
Expand Down Expand Up @@ -3526,6 +3527,18 @@ void tst_qdeclarativeecmascript::aliasWritesOverrideBindings()
}
}

// Allow an alais to a composite element
// QTBUG-20200
void tst_qdeclarativeecmascript::aliasToCompositeElement()
{
QDeclarativeComponent component(&engine, TEST_FILE("aliasToCompositeElement.qml"));

QObject *object = component.create();
QVERIFY(object != 0);

delete object;
}

void tst_qdeclarativeecmascript::revisionErrors()
{
{
Expand Down

0 comments on commit 5249c88

Please sign in to comment.