Commit 24829c76 authored by Marco Bubke's avatar Marco Bubke Committed by Kai Koehne

Add asserts for needed lists functions

The interface for QDeclarativeListReference is bad because in Bauhaus we
need to remove many(all) items which a maybe never removed in the
runtime. So this canLear, canAppend functions renders bauhaus useless.
parent b92821c6
......@@ -336,14 +336,18 @@ static void removeObjectFromList(const QDeclarativeProperty &metaProperty, QObje
QObjectList objectList;
Q_ASSERT(listReference.canCount());
Q_ASSERT(listReference.canAt());
for(int i = 0; i < count; i ++) {
QObject *listItem = listReference.at(i);
if (listItem != objectToBeRemoved)
objectList.append(listItem);
}
Q_ASSERT(listReference.canClear());
listReference.clear();
Q_ASSERT(listReference.canAppend());
foreach(QObject *object, objectList)
listReference.append(object);
}
......@@ -367,6 +371,7 @@ void ObjectNodeInstance::addToNewProperty(QObject *object, QObject *newParent, c
if (isList(metaProperty)) {
QDeclarativeListReference list = qvariant_cast<QDeclarativeListReference>(metaProperty.read());
Q_ASSERT(list.canAppend());
list.append(object);
} else if (isObject(metaProperty)) {
metaProperty.write(objectToVariant(object));
......@@ -454,10 +459,15 @@ void ObjectNodeInstance::deleteObjectsInList(const QDeclarativeProperty &metaPro
QObjectList objectList;
QDeclarativeListReference list = qvariant_cast<QDeclarativeListReference>(metaProperty.read());
Q_ASSERT(list.canCount());
Q_ASSERT(list.canAt());
for(int i = 0; i < list.count(); i++) {
objectList += list.at(i);
}
Q_ASSERT(list.canClear());
list.clear();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment