diff options
| author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2018-05-22 14:04:53 +0200 |
|---|---|---|
| committer | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2018-05-25 11:21:59 +0000 |
| commit | cf9c07539c3e6a30f5f73fd1b2d5feebf03d716a (patch) | |
| tree | 06e15e9018afafbc1dd851ebb81f9499f5a1653f /src | |
| parent | 444e5c1c4a087a080914e1cedd3c6ab00875ff94 (diff) | |
TableView: check if the model can produce items before loading
If you assign a non-empty model, the model can still return a count
of zero if something else is amiss, like the delegate being null.
So we need to do en extra check for this before we load the first
top-left item, otherwise we'll hit an assert later in the loading process.
Change-Id: I747868faf7955b8784b2957505ae03e5b1aa0b45
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src')
| -rw-r--r-- | src/quick/items/qquicktableview.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp index 5bc47a2b07..b3802b7694 100644 --- a/src/quick/items/qquicktableview.cpp +++ b/src/quick/items/qquicktableview.cpp @@ -965,6 +965,9 @@ void QQuickTableViewPrivate::loadInitialTopLeftItem() if (tableSize.isEmpty()) return; + if (model->count() == 0) + return; + // Load top-left item. After loaded, loadItemsInsideRect() will take // care of filling out the rest of the table. loadRequest.begin(QPoint(0, 0), QQmlIncubator::AsynchronousIfNested); @@ -1007,8 +1010,7 @@ void QQuickTableViewPrivate::loadAndUnloadVisibleEdges() if (loadedItems.isEmpty()) { // We need at least the top-left item to be loaded before we can // start loading edges around it. Not having a top-left item at - // this point means that the model is empty (or row and and column - // is 0) since we have no active load request. + // this point means that the model is empty (or no delegate). return; } @@ -1115,7 +1117,7 @@ void QQuickTableViewPrivate::updatePolish() endRebuildTable(); if (loadedItems.isEmpty()) { - qCDebug(lcTableViewDelegateLifecycle()) << "no items loaded, meaning empty model or row/column == 0"; + qCDebug(lcTableViewDelegateLifecycle()) << "no items loaded, meaning empty model or no delegate"; return; } |
