From bbf5777dc2688fd1f7ef87d8302b5a77c301472d Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 23 Mar 2020 15:39:25 +0100 Subject: TableView: Clarify the rows/columns docs about inserting/removing Fixes: QTBUG-82904 Change-Id: Ib44122fd0c2e5fc83cfef1368ed4ec0f3b1951af Reviewed-by: Richard Moe Gustavsen Reviewed-by: Mitch Curtis --- src/quick/items/qquicktableview.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/quick/items/qquicktableview.cpp') diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp index b236216ac7..ceeb952d7d 100644 --- a/src/quick/items/qquicktableview.cpp +++ b/src/quick/items/qquicktableview.cpp @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** ** ** Copyright (C) 2018 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ @@ -193,8 +193,10 @@ \qmlproperty int QtQuick::TableView::rows \readonly - This property holds the number of rows in the table. This is - equal to the number of rows in the model. + This property holds the number of rows in the table. + + \note \a rows is usually equal to the number of rows in the model, but can + temporarily differ until all pending model changes have been processed. This property is read only. */ @@ -203,9 +205,12 @@ \qmlproperty int QtQuick::TableView::columns \readonly - This property holds the number of columns in the table. This is - equal to the number of columns in the model. If the model is - a list, columns will be \c 1. + This property holds the number of rows in the table. + + \note \a columns is usually equal to the number of columns in the model, but + can temporarily differ until all pending model changes have been processed. + + If the model is a list, columns will be \c 1. This property is read only. */ -- cgit v1.2.3 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