aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2020-04-21 09:31:42 +0200
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2020-04-21 09:31:42 +0200
commit560bc348d86aba6cef5fdf88bc9d7304dd914bc8 (patch)
tree3eaab505c070f61ecf0022d36810dde5becb68d1
parent7dc0de374300d66ed72f15820a4ebb78849ae0e7 (diff)
parent23a000f9a14889753a63cd73de2c61e49bb7e0d8 (diff)
Merge remote-tracking branch 'origin/5.14.2' into 5.14
-rw-r--r--dist/changes-5.14.256
-rw-r--r--src/qmlmodels/qqmltablemodel.cpp21
-rw-r--r--src/quick/items/qquicktextinput.cpp3
-rw-r--r--tests/auto/qml/qqmltablemodel/data/intAndDouble.qml86
-rw-r--r--tests/auto/qml/qqmltablemodel/tst_qqmltablemodel.cpp71
5 files changed, 231 insertions, 6 deletions
diff --git a/dist/changes-5.14.2 b/dist/changes-5.14.2
new file mode 100644
index 0000000000..63b4b2fe46
--- /dev/null
+++ b/dist/changes-5.14.2
@@ -0,0 +1,56 @@
+Qt 5.14.2 is a bug-fix release. It maintains both forward and backward
+compatibility (source and binary) with Qt 5.14.0 through 5.14.1.
+
+For more details, refer to the online documentation included in this
+distribution. The documentation is also available online:
+
+https://doc.qt.io/qt-5/index.html
+
+The Qt version 5.14 series is binary compatible with the 5.13.x series.
+Applications compiled for 5.13 will continue to run with 5.14.
+
+Some of the changes listed in this file include issue tracking numbers
+corresponding to tasks in the Qt Bug Tracker:
+
+https://bugreports.qt.io/
+
+Each of these identifiers can be entered in the bug tracker to obtain more
+information about a particular change.
+
+****************************************************************************
+* QtQml *
+****************************************************************************
+
+ - [QTBUG-82000] Fixed leaking metatypes in QQmlTableInstanceModel.
+ - [QTBUG-82017] QQmlProperty and Connections now work for properties
+ that start with '_'.
+ - [QTBUG-81945] Fixed an invalid type bug when using an array of strings
+ as a ListView model.
+ - [QTBUG-80916] Conversion between container types and QJSValue arrays is
+ now bidirectionally supported.
+ - [QTBUG-81699] Fixed the "qmlRegisterType requires absolute URLs." error.
+ - [QTBUG-79553] Fixed a crash by avoiding storage of user-created objects
+ in QQmlValueType.
+ - [QTBUG-81581] We now check for exceptions before using the result of a
+ JS function call.
+
+****************************************************************************
+* QtQuick *
+****************************************************************************
+ - [QTBUG-73683] Fix a layout bug that caused an infinite loop when the width
+ of a RowLayout containing Text with WrapAtWordBoundaryOrAnywhere changed.
+ - [QTBUG-78284] Fixed VoiceOver in QtWebEngine and other cases in which
+ the focused item must be discovered recursively for accessibility.
+ - [QTBUG-76362] Fix some bugs with snapping in a ListView with a header.
+ - [QTBUG-81098] Fixed division by zero in Flickable with binding to visibleArea.
+ - [QTBUG-82002] QQuickLoader emits statusChanged only when it really changed.
+
+****************************************************************************
+* Platform Specific Changes *
+****************************************************************************
+ - [QTBUG-81021] Plugins built with debug info with *d.dll filenames are
+ again found at runtime on Windows.
+ - [QTBUG-80843] Fixed a cmake problem with qt5_import_qml_plugins()
+ - [QTBUG-38296] qmlimportscanner and androiddeployqt now detect when the
+ Particles module is needed, so it's no longer an explicit dependency
+ on Android.
diff --git a/src/qmlmodels/qqmltablemodel.cpp b/src/qmlmodels/qqmltablemodel.cpp
index f190ad86b1..fab20f7410 100644
--- a/src/qmlmodels/qqmltablemodel.cpp
+++ b/src/qmlmodels/qqmltablemodel.cpp
@@ -1028,11 +1028,24 @@ bool QQmlTableModel::validateNewRow(const char *functionName, const QVariant &ro
}
const QVariant rolePropertyValue = rowAsMap.value(roleData.name);
+
if (rolePropertyValue.type() != roleData.type) {
- qmlWarning(this).quote() << functionName << ": expected the property named "
- << roleData.name << " to be of type " << roleData.typeName
- << ", but got " << QString::fromLatin1(rolePropertyValue.typeName()) << " instead";
- return false;
+ if (!rolePropertyValue.canConvert(int(roleData.type))) {
+ qmlWarning(this).quote() << functionName << ": expected the property named "
+ << roleData.name << " to be of type " << roleData.typeName
+ << ", but got " << QString::fromLatin1(rolePropertyValue.typeName())
+ << " instead";
+ return false;
+ }
+
+ QVariant effectiveValue = rolePropertyValue;
+ if (!effectiveValue.convert(int(roleData.type))) {
+ qmlWarning(this).nospace() << functionName << ": failed converting value "
+ << rolePropertyValue << " set at column " << columnIndex << " with role "
+ << QString::fromLatin1(rolePropertyValue.typeName()) << " to "
+ << roleData.typeName;
+ return false;
+ }
}
}
}
diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp
index 11a6600b74..ee51711d34 100644
--- a/src/quick/items/qquicktextinput.cpp
+++ b/src/quick/items/qquicktextinput.cpp
@@ -2901,8 +2901,7 @@ void QQuickTextInputPrivate::updateDisplayText(bool forceUpdate)
// characters)
QChar* uc = str.data();
for (int i = 0; i < str.length(); ++i) {
- if ((uc[i].unicode() < 0x20 && uc[i] != QChar::Tabulation)
- || uc[i] == QChar::LineSeparator
+ if (uc[i] == QChar::LineSeparator
|| uc[i] == QChar::ParagraphSeparator
|| uc[i] == QChar::ObjectReplacementCharacter)
uc[i] = QChar(0x0020);
diff --git a/tests/auto/qml/qqmltablemodel/data/intAndDouble.qml b/tests/auto/qml/qqmltablemodel/data/intAndDouble.qml
new file mode 100644
index 0000000000..261bc8a115
--- /dev/null
+++ b/tests/auto/qml/qqmltablemodel/data/intAndDouble.qml
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.12
+import Qt.labs.qmlmodels 1.0
+
+Item {
+ id: root
+ width: 200
+ height: 200
+
+ property alias testModel: testModel
+ property alias tableView: tableView
+
+ function appendBanana() {
+ testModel.appendRow({
+ fruit: "Banana",
+ price: 3.5
+ })
+ }
+
+ function appendStrawberry() {
+ testModel.appendRow({
+ fruit: "Strawberry",
+ price: "5"
+ })
+ }
+
+ function appendInvalid() {
+ testModel.appendRow({
+ fruit: "Pear",
+ price: "Invalid"
+ })
+ }
+
+ TableModel {
+ id: testModel
+ objectName: "testModel"
+
+ TableModelColumn { display: "fruit" }
+ TableModelColumn { display: "price" }
+ rows: [
+ {
+ fruit: "Apple",
+ price: 1
+ },
+ {
+ fruit: "Orange",
+ price: 2
+ }
+ ]
+ }
+ TableView {
+ id: tableView
+ anchors.fill: parent
+ model: testModel
+ delegate: Text {
+ text: model.display
+ }
+ }
+}
diff --git a/tests/auto/qml/qqmltablemodel/tst_qqmltablemodel.cpp b/tests/auto/qml/qqmltablemodel/tst_qqmltablemodel.cpp
index d913bcdf9a..321896a8f3 100644
--- a/tests/auto/qml/qqmltablemodel/tst_qqmltablemodel.cpp
+++ b/tests/auto/qml/qqmltablemodel/tst_qqmltablemodel.cpp
@@ -59,6 +59,7 @@ private slots:
void dataAndEditing();
void omitTableModelColumnIndex();
void complexRow();
+ void appendRowWithDouble();
};
void tst_QQmlTableModel::appendRemoveRow()
@@ -975,6 +976,76 @@ void tst_QQmlTableModel::complexRow()
QCOMPARE(model->data(model->index(1, 1, QModelIndex()), roleNames.key("display")).toInt(), 33);
}
+void tst_QQmlTableModel::appendRowWithDouble()
+{
+ QQuickView view(testFileUrl("intAndDouble.qml"));
+ QCOMPARE(view.status(), QQuickView::Ready);
+ view.show();
+ QVERIFY(QTest::qWaitForWindowActive(&view));
+
+ QQmlTableModel *model = view.rootObject()->property("testModel").value<QQmlTableModel*>();
+ QVERIFY(model);
+ QCOMPARE(model->rowCount(), 2);
+ QCOMPARE(model->columnCount(), 2);
+
+ QSignalSpy columnCountSpy(model, SIGNAL(columnCountChanged()));
+ QVERIFY(columnCountSpy.isValid());
+
+ QSignalSpy rowCountSpy(model, SIGNAL(rowCountChanged()));
+ QVERIFY(rowCountSpy.isValid());
+
+ QQuickTableView *tableView = view.rootObject()->property("tableView").value<QQuickTableView*>();
+ QVERIFY(tableView);
+ QCOMPARE(tableView->rows(), 2);
+ QCOMPARE(tableView->columns(), 2);
+
+ QVERIFY(QMetaObject::invokeMethod(view.rootObject(), "appendBanana"));
+ QCOMPARE(model->rowCount(), 3);
+ QCOMPARE(model->columnCount(), 2);
+ const QHash<int, QByteArray> roleNames = model->roleNames();
+ const int roleKey = roleNames.key("display");
+ QCOMPARE(model->data(model->index(0, 1, QModelIndex()), roleKey).toString(),
+ QLatin1String("1"));
+ QCOMPARE(model->data(model->index(2, 0, QModelIndex()), roleKey).toString(),
+ QLatin1String("Banana"));
+ QCOMPARE(model->data(model->index(2, 1, QModelIndex()), roleKey).toDouble(), 3.5);
+ QCOMPARE(model->data(model->index(2, 1, QModelIndex()), roleKey).toString(),
+ QLatin1String("3.5"));
+ QCOMPARE(columnCountSpy.count(), 0);
+ QCOMPARE(rowCountSpy.count(), 1);
+ QTRY_COMPARE(tableView->rows(), 3);
+ QCOMPARE(tableView->columns(), 2);
+
+ rowCountSpy.clear();
+
+ QVERIFY(QMetaObject::invokeMethod(view.rootObject(), "appendStrawberry"));
+ QCOMPARE(model->rowCount(), 4);
+ QCOMPARE(model->columnCount(), 2);
+ QCOMPARE(model->data(model->index(3, 0, QModelIndex()), roleKey).toString(),
+ QLatin1String("Strawberry"));
+ QCOMPARE(model->data(model->index(3, 1, QModelIndex()), roleKey).toDouble(), 5);
+ QCOMPARE(model->data(model->index(3, 1, QModelIndex()), roleKey).toString(),
+ QLatin1String("5"));
+ QCOMPARE(columnCountSpy.count(), 0);
+ QCOMPARE(rowCountSpy.count(), 1);
+ QTRY_COMPARE(tableView->rows(), 4);
+ QCOMPARE(tableView->columns(), 2);
+
+ rowCountSpy.clear();
+ QTest::ignoreMessage(QtWarningMsg,
+ QRegularExpression(".*appendRow\\(\\): failed converting value "
+ "QVariant\\(QString, \"Invalid\"\\) set at column 1 with "
+ "role \"QString\" to \"int\""));
+ QVERIFY(QMetaObject::invokeMethod(view.rootObject(), "appendInvalid"));
+ // Nothing should change
+ QCOMPARE(model->rowCount(), 4);
+ QCOMPARE(model->columnCount(), 2);
+ QCOMPARE(columnCountSpy.count(), 0);
+ QCOMPARE(rowCountSpy.count(), 0);
+ QCOMPARE(tableView->rows(), 4);
+ QCOMPARE(tableView->columns(), 2);
+}
+
QTEST_MAIN(tst_QQmlTableModel)
#include "tst_qqmltablemodel.moc"