From 0ebc0a321a4f40089318ab4a7bd31b84ffbf8393 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Thu, 2 Apr 2020 16:19:25 +0200 Subject: QQuickTableView: fix crash in tableLayoutToString() The function QQuickTableViewPrivate::tableLayoutToString() returns a string used for debugging the loaded table. If the table is empty, it will crash/assert while trying to read data out of an empty vector. This patch will check for this case before creating the string. Change-Id: I47c01b3c8447ccc7424fe475f38e22ff70c681d8 Reviewed-by: Shawn Rutledge --- src/quick/items/qquicktableview.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/quick/items/qquicktableview.cpp') diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp index ceeb952d7d..c7882fb2b1 100644 --- a/src/quick/items/qquicktableview.cpp +++ b/src/quick/items/qquicktableview.cpp @@ -462,6 +462,8 @@ QQuickTableViewPrivate::~QQuickTableViewPrivate() QString QQuickTableViewPrivate::tableLayoutToString() const { + if (loadedItems.isEmpty()) + return QLatin1String("table is empty!"); return QString(QLatin1String("table cells: (%1,%2) -> (%3,%4), item count: %5, table rect: %6,%7 x %8,%9")) .arg(leftColumn()).arg(topRow()) .arg(rightColumn()).arg(bottomRow()) -- cgit v1.2.3