summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
index 4365ea3..751284d 100644
--- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
+++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
@@ -353,6 +353,7 @@ public:
friend class QDeclarativeVisualDataModelData;
bool m_metaDataCreated;
bool m_metaDataCacheable;
+ bool m_delegateValidated;
QDeclarativeVisualDataModelData *data(QObject *item);
@@ -560,7 +561,7 @@ QDeclarativeVisualDataModelParts::QDeclarativeVisualDataModelParts(QDeclarativeV
QDeclarativeVisualDataModelPrivate::QDeclarativeVisualDataModelPrivate(QDeclarativeContext *ctxt)
: m_listModelInterface(0), m_abstractItemModel(0), m_visualItemModel(0), m_delegate(0)
, m_context(ctxt), m_parts(0), m_delegateDataType(0), m_metaDataCreated(false)
-, m_metaDataCacheable(false), m_listAccessor(0)
+, m_metaDataCacheable(false), m_delegateValidated(false), m_listAccessor(0)
{
}
@@ -768,6 +769,7 @@ void QDeclarativeVisualDataModel::setDelegate(QDeclarativeComponent *delegate)
Q_D(QDeclarativeVisualDataModel);
bool wasValid = d->m_delegate != 0;
d->m_delegate = delegate;
+ d->m_delegateValidated = false;
if (!wasValid && d->modelCount() && d->m_delegate) {
emit itemsInserted(0, d->modelCount());
emit countChanged();
@@ -987,6 +989,7 @@ QDeclarativeItem *QDeclarativeVisualDataModel::item(int index, const QByteArray
if (d->modelCount() <= 0 || !d->m_delegate)
return 0;
QObject *nobj = d->m_cache.getItem(index);
+ bool needComplete = false;
if (!nobj) {
QDeclarativeContext *ccontext = d->m_context;
if (!ccontext) ccontext = qmlContext(this);
@@ -997,6 +1000,8 @@ QDeclarativeItem *QDeclarativeVisualDataModel::item(int index, const QByteArray
nobj = d->m_delegate->beginCreate(ctxt);
if (complete)
d->m_delegate->completeCreate();
+ else
+ needComplete = true;
if (nobj) {
QDeclarative_setParent_noEvent(ctxt, nobj);
QDeclarative_setParent_noEvent(data, nobj);
@@ -1020,8 +1025,13 @@ QDeclarativeItem *QDeclarativeVisualDataModel::item(int index, const QByteArray
}
}
if (!item) {
+ if (needComplete)
+ d->m_delegate->completeCreate();
d->m_cache.releaseItem(nobj);
- qmlInfo(d->m_delegate) << QDeclarativeVisualDataModel::tr("Delegate component must be Item type.");
+ if (!d->m_delegateValidated) {
+ qmlInfo(d->m_delegate) << QDeclarativeVisualDataModel::tr("Delegate component must be Item type.");
+ d->m_delegateValidated = true;
+ }
}
return item;