From f3dda7959e8807fcbc0f725ac39b0e0ebe0ec862 Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 4 Jan 2019 16:44:00 +0000 Subject: [PATCH] For very large tables, don't fallback to rendering all rows * lastRow can return -1 in some situations where there's no last row visible, but we don't want to render potentially millions of invisible rows. --- qrenderdoc/Widgets/Extended/RDTableView.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qrenderdoc/Widgets/Extended/RDTableView.cpp b/qrenderdoc/Widgets/Extended/RDTableView.cpp index a38478676..ef229f886 100644 --- a/qrenderdoc/Widgets/Extended/RDTableView.cpp +++ b/qrenderdoc/Widgets/Extended/RDTableView.cpp @@ -233,7 +233,11 @@ void RDTableView::paintEvent(QPaintEvent *e) int firstRow = qMax(verticalHeader()->visualIndexAt(0), 0); int lastRow = verticalHeader()->visualIndexAt(viewport()->height()); if(lastRow < 0) - lastRow = verticalHeader()->count() - 1; + { + // if lastRow is negative, display as many will fit. This is a reasonable upper bound without + // displaying all rows which could be massive + lastRow = firstRow + (viewport()->height() / qMax(1, rowHeight(firstRow))) + 1; + } lastRow = qMin(lastRow, verticalHeader()->count() - 1); int firstCol = qMax(horizontalHeader()->visualIndexAt(horizontalHeader()->pinnedWidth() + 1), 0);