From 85554f7f262ff5aae15562b11c6d08bcc03c961f Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Thu, 8 Sep 2011 15:13:42 +1000 Subject: Fix QDeclarativeListProperty assignment This commit ensures that a QDeclarativeListReference can be assigned to another QDeclarativeListProperty, by retrieving each element in the list reference and converting to the appropriate type before appending to the target list property. Task-number: QTBUG-16316 Change-Id: Id8858058f052a53bf43eadc085fd278654478d77 Reviewed-on: http://codereview.qt-project.org/4388 Reviewed-by: Qt Sanity Bot Reviewed-by: Aaron Kennedy --- src/declarative/qml/qdeclarativeproperty.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/declarative') diff --git a/src/declarative/qml/qdeclarativeproperty.cpp b/src/declarative/qml/qdeclarativeproperty.cpp index 60e785510a..acc2cfb752 100644 --- a/src/declarative/qml/qdeclarativeproperty.cpp +++ b/src/declarative/qml/qdeclarativeproperty.cpp @@ -1215,7 +1215,16 @@ bool QDeclarativePropertyPrivate::write(QObject *object, const QDeclarativePrope prop.clear(&prop); - if (value.userType() == qMetaTypeId >()) { + if (value.userType() == qMetaTypeId()) { + QDeclarativeListReference qdlr = value.value(); + + for (int ii = 0; ii < qdlr.count(); ++ii) { + QObject *o = qdlr.at(ii); + if (o && !canConvert(o->metaObject(), listType)) + o = 0; + prop.append(&prop, (void *)o); + } + } else if (value.userType() == qMetaTypeId >()) { const QList &list = qvariant_cast >(value); for (int ii = 0; ii < list.count(); ++ii) { -- cgit v1.2.3