aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquicktableview.cpp
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2020-04-02 16:19:25 +0200
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2020-04-07 15:04:37 +0200
commit0ebc0a321a4f40089318ab4a7bd31b84ffbf8393 (patch)
tree59d8a1a1b0011a3d500a7d220292b41990b32d1e /src/quick/items/qquicktableview.cpp
parent6387fdd3295d21adf1fb62d5101d286048d0c664 (diff)
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 <shawn.rutledge@qt.io>
Diffstat (limited to 'src/quick/items/qquicktableview.cpp')
-rw-r--r--src/quick/items/qquicktableview.cpp2
1 files changed, 2 insertions, 0 deletions
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())