diff options
author | Martin Jones <martin.jones@nokia.com> | 2009-05-12 05:20:16 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2009-05-12 05:20:16 (GMT) |
commit | 4e19d0393dd4b4ddcdbe1677987d9370a5d605bb (patch) | |
tree | 2a4ff75f98fab22c4073e3ab4cf5cacf467e83f8 | |
parent | 8d90fe1e4a3d50b64cff84ac10bfa2e6a17a35b9 (diff) | |
download | Qt-4e19d0393dd4b4ddcdbe1677987d9370a5d605bb.zip Qt-4e19d0393dd4b4ddcdbe1677987d9370a5d605bb.tar.gz Qt-4e19d0393dd4b4ddcdbe1677987d9370a5d605bb.tar.bz2 |
More robust error handling (in ListView) and reporting (in VisualModel).
-rw-r--r-- | src/declarative/fx/qfxlistview.cpp | 33 | ||||
-rw-r--r-- | src/declarative/fx/qfxvisualitemmodel.cpp | 13 | ||||
-rw-r--r-- | src/declarative/qml/qmlvme.cpp | 1 |
3 files changed, 30 insertions, 17 deletions
diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp index fcd6e1f..46166e2 100644 --- a/src/declarative/fx/qfxlistview.cpp +++ b/src/declarative/fx/qfxlistview.cpp @@ -438,6 +438,7 @@ FxListItem *QFxListViewPrivate::createItem(int modelIndex) else QObject::connect(listItem->item, SIGNAL(widthChanged()), q, SLOT(itemResized())); } + return listItem; } @@ -484,7 +485,8 @@ void QFxListViewPrivate::refill(qreal from, qreal to) int pos = itemEnd + 1; while (modelIndex < model->count() && pos <= to) { //qDebug() << "refill: append item" << modelIndex; - item = getItem(modelIndex); + if (!(item = getItem(modelIndex))) + break; item->setPosition(pos); pos += item->size(); visibleItems.append(item); @@ -493,7 +495,8 @@ void QFxListViewPrivate::refill(qreal from, qreal to) } while (visibleIndex > 0 && visibleIndex <= model->count() && visiblePos > from) { //qDebug() << "refill: prepend item" << visibleIndex-1 << "current top pos" << visiblePos; - item = getItem(visibleIndex-1); + if (!(item = getItem(visibleIndex-1))) + break; --visibleIndex; visiblePos -= item->size(); item->setPosition(visiblePos); @@ -719,26 +722,30 @@ void QFxListViewPrivate::updateCurrent(int modelIndex) currentItem = visibleItem(modelIndex); if (!currentItem) { currentItem = getItem(modelIndex); - if (modelIndex == visibleIndex - 1) { - // We can calculate exact postion in this case - currentItem->setPosition(visibleItems.first()->position() - currentItem->size()); - } else { - // Create current item now and position as best we can. - // Its position will be corrected when it becomes visible. - currentItem->setPosition(positionAt(modelIndex)); + if (currentItem) { + if (modelIndex == visibleIndex - 1) { + // We can calculate exact postion in this case + currentItem->setPosition(visibleItems.first()->position() - currentItem->size()); + } else { + // Create current item now and position as best we can. + // Its position will be corrected when it becomes visible. + currentItem->setPosition(positionAt(modelIndex)); + } } } currentIndex = modelIndex; fixCurrentVisibility = true; - if (oldCurrentItem && oldCurrentItem->item != currentItem->item) + if (oldCurrentItem && (!currentItem || oldCurrentItem->item != currentItem->item)) oldCurrentItem->attached->setIsCurrentItem(false); - currentItem->item->setFocus(true); - currentItem->attached->setIsCurrentItem(true); + if (currentItem) { + currentItem->item->setFocus(true); + currentItem->attached->setIsCurrentItem(true); + } updateHighlight(); emit q->currentIndexChanged(); // Release the old current item if (oldCurrentItem && !visibleItem(oldCurrentIndex)) { - if (oldCurrentItem->item == currentItem->item) + if (!currentItem || oldCurrentItem->item == currentItem->item) delete oldCurrentItem; else releaseItem(oldCurrentItem); diff --git a/src/declarative/fx/qfxvisualitemmodel.cpp b/src/declarative/fx/qfxvisualitemmodel.cpp index 61f08de..533917e 100644 --- a/src/declarative/fx/qfxvisualitemmodel.cpp +++ b/src/declarative/fx/qfxvisualitemmodel.cpp @@ -512,12 +512,17 @@ QFxItem *QFxVisualItemModel::item(int index, const QByteArray &viewId, bool comp nobj = d->m_delegate->beginCreate(ctxt); if (complete) d->m_delegate->completeCreate(); - ctxt->setParent(nobj); - data->setParent(nobj); + if (nobj) { + ctxt->setParent(nobj); + data->setParent(nobj); - d->m_cache.insert(index, nobj); + d->m_cache.insert(index, nobj); + } else { + delete data; + delete ctxt; + qWarning() << d->m_delegate->errors(); + } } - QFxItem *item = qobject_cast<QFxItem *>(nobj); if (!item) { QmlPackage *package = qobject_cast<QmlPackage *>(nobj); diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp index 794c836..240dcc1 100644 --- a/src/declarative/qml/qmlvme.cpp +++ b/src/declarative/qml/qmlvme.cpp @@ -1067,6 +1067,7 @@ QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledComponent *comp, int start, in QmlEnginePrivate::clear(bindValues); QmlEnginePrivate::clear(parserStatus); + qWarning() << errors().at(0); return 0; } |