diff options
author | Martin Jones <martin.jones@nokia.com> | 2009-05-14 03:38:20 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2009-05-14 03:38:20 (GMT) |
commit | 875c4af96f094dad9158d77e926049dbf9a75475 (patch) | |
tree | bf200b29eec09e72c23ed0537b89e5e7754a091d /src/declarative | |
parent | 46e7c3f7132aac3838bca4510675f8ad7f70a115 (diff) | |
download | Qt-875c4af96f094dad9158d77e926049dbf9a75475.zip Qt-875c4af96f094dad9158d77e926049dbf9a75475.tar.gz Qt-875c4af96f094dad9158d77e926049dbf9a75475.tar.bz2 |
GridView shall not crash when given a broken delegate.
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/fx/qfxgridview.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/declarative/fx/qfxgridview.cpp b/src/declarative/fx/qfxgridview.cpp index 5156d06..e745b24 100644 --- a/src/declarative/fx/qfxgridview.cpp +++ b/src/declarative/fx/qfxgridview.cpp @@ -409,7 +409,8 @@ void QFxGridViewPrivate::refill(qreal from, qreal to) FxGridItem *item = 0; while (modelIndex < model->count() && rowPos <= to) { //qDebug() << "refill: append item" << modelIndex; - item = getItem(modelIndex); + if (!(item = getItem(modelIndex))) + break; item->setPosition(colPos, rowPos); visibleItems.append(item); colPos += colSize(); @@ -431,7 +432,8 @@ void QFxGridViewPrivate::refill(qreal from, qreal to) } while (visibleIndex > 0 && rowPos + rowSize() - 1 >= from){ //qDebug() << "refill: prepend item" << visibleIndex-1 << "top pos" << rowPos << colPos; - item = getItem(visibleIndex-1); + if (!(item = getItem(visibleIndex-1))) + break; --visibleIndex; item->setPosition(colPos, rowPos); visibleItems.prepend(item); @@ -629,14 +631,17 @@ void QFxGridViewPrivate::updateCurrent(int modelIndex) currentItem = visibleItem(modelIndex); if (!currentItem) { currentItem = getItem(modelIndex); - currentItem->setPosition(colPosAt(modelIndex), rowPosAt(modelIndex)); + if (currentItem) + currentItem->setPosition(colPosAt(modelIndex), rowPosAt(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 |