diff options
author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2019-04-24 11:46:37 +0200 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2019-04-29 10:27:36 +0000 |
commit | 8fb8cfd040a5fa8c4caa5715efe1328da9c49536 (patch) | |
tree | 808c3d874ff5e5d4b6442fd1f0cae661ea585a8f /src/quick | |
parent | 9e5ca92712da3392d1f2957dc1e546cdddd1ce0a (diff) |
QQuickTableView: avoid building syncView children before syncView has finished
If you put two tables inside an async loader, with one being
the syncView for the other, the syncView child will start
loading items async simultaneously with the syncView.
This is unnecessary, and steals loading resources, since
the child will have to rebuild anyway once the syncView has
completed loading. So return early from the recursiveUpdateTable
call before handling the children if we detect that the parent
is not done.
Change-Id: I8c0badaf3cfa3a353a650e5f38f381bf9a7b98f9
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quick')
-rw-r--r-- | src/quick/items/qquicktableview.cpp | 22 | ||||
-rw-r--r-- | src/quick/items/qquicktableview_p_p.h | 2 |
2 files changed, 15 insertions, 9 deletions
diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp index c30d40138e..60bf42fb10 100644 --- a/src/quick/items/qquicktableview.cpp +++ b/src/quick/items/qquicktableview.cpp @@ -1866,14 +1866,16 @@ bool QQuickTableViewPrivate::updateTableRecursive() return false; } - updateTable(); + const bool updateComplete = updateTable(); + if (!updateComplete) + return false; for (auto syncChild : qAsConst(syncChildren)) { auto syncChild_d = syncChild->d_func(); syncChild_d->scheduledRebuildOptions |= rebuildOptions; - const bool updated = syncChild_d->updateTableRecursive(); - if (!updated) + const bool descendantUpdateComplete = syncChild_d->updateTableRecursive(); + if (!descendantUpdateComplete) return false; } @@ -1882,11 +1884,13 @@ bool QQuickTableViewPrivate::updateTableRecursive() return true; } -void QQuickTableViewPrivate::updateTable() +bool QQuickTableViewPrivate::updateTable() { // Whenever something changes, e.g viewport moves, spacing is set to a // new value, model changes etc, this function will end up being called. Here // we check what needs to be done, and load/unload cells accordingly. + // If we cannot complete the update (because we need to wait for an item + // to load async), we return false. Q_TABLEVIEW_ASSERT(!polishing, "recursive updatePolish() calls are not allowed!"); QBoolBlocker polishGuard(polishing, true); @@ -1896,25 +1900,27 @@ void QQuickTableViewPrivate::updateTable() // as an atomic operation, which means that we don't continue doing anything else until all // items have been received and laid out. Note that updatePolish is then called once more // after the loadRequest has completed to handle anything that might have occurred in-between. - return; + return false; } if (rebuildState != RebuildState::Done) { processRebuildTable(); - return; + return rebuildState == RebuildState::Done; } syncWithPendingChanges(); if (rebuildState == RebuildState::Begin) { processRebuildTable(); - return; + return rebuildState == RebuildState::Done; } if (loadedItems.isEmpty()) - return; + return !loadRequest.isActive(); loadAndUnloadVisibleEdges(); + + return !loadRequest.isActive(); } void QQuickTableViewPrivate::fixup(QQuickFlickablePrivate::AxisData &data, qreal minExtent, qreal maxExtent) diff --git a/src/quick/items/qquicktableview_p_p.h b/src/quick/items/qquicktableview_p_p.h index ab7c0c3275..728896d30e 100644 --- a/src/quick/items/qquicktableview_p_p.h +++ b/src/quick/items/qquicktableview_p_p.h @@ -315,7 +315,7 @@ public: QQuickTableView *rootSyncView() const; bool updateTableRecursive(); - void updateTable(); + bool updateTable(); void relayoutTable(); void relayoutTableItems(); |