aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2018-05-23 10:09:01 +0200
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2018-05-25 11:21:49 +0000
commit444e5c1c4a087a080914e1cedd3c6ab00875ff94 (patch)
tree49ade7bf7e597dfc1dc29dc2b41fd0cacb171c62 /src/quick
parent4d9e329df599da96927d559931eabd0062bcf147 (diff)
TableView: update viewport rect from within updatePolish()
Don't calculate the viewport rect from within QQuickTableView::geometryChanged(), since we anyway recalculate it later from within updatePolish(). This is a follow up of f61a49e, that implements the same logic. Change-Id: I42aaa9b75c1b0d51e4d99295de96b373549331ab Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quick')
-rw-r--r--src/quick/items/qquicktableview.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp
index f32f5823c5..5bc47a2b07 100644
--- a/src/quick/items/qquicktableview.cpp
+++ b/src/quick/items/qquicktableview.cpp
@@ -1098,8 +1098,12 @@ void QQuickTableViewPrivate::updatePolish()
return;
}
- // viewportrect describes the part of the content view that is actually visible
+ // viewportRect describes the part of the content view that is actually visible. Since a
+ // negative width/height can happen (e.g during start-up), we check for this to avoid rebuilding
+ // the table (and e.g calculate initial row/column sizes) based on a premature viewport rect.
viewportRect = QRectF(q->contentX(), q->contentY(), q->width(), q->height());
+ if (!viewportRect.isValid())
+ return;
if (tableInvalid) {
beginRebuildTable();
@@ -1415,13 +1419,10 @@ void QQuickTableView::geometryChanged(const QRectF &newGeometry, const QRectF &o
{
Q_D(QQuickTableView);
QQuickFlickable::geometryChanged(newGeometry, oldGeometry);
-
- QRectF rect = QRectF(contentX(), contentY(), newGeometry.width(), newGeometry.height());
- if (!rect.isValid())
- return;
-
- d->viewportRect = rect;
- polish();
+ // We update the viewport rect from within updatePolish to
+ // ensure that we update when we're ready to update, and not
+ // while we're in the middle of loading/unloading edges.
+ d->updatePolish();
}
void QQuickTableView::viewportMoved(Qt::Orientations orientation)