aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/labsmodels
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2020-04-21 21:22:54 +0200
committerLiang Qi <liang.qi@qt.io>2020-04-22 17:59:46 +0200
commit5b083d89e66082ad50d39b5bc6116e0b0319087e (patch)
tree6c1f5f50958acfd1112d75932f1e17e020f03255 /src/imports/labsmodels
parent6555642db7b3b992335f98dc01863db4beea3fd4 (diff)
parent560bc348d86aba6cef5fdf88bc9d7304dd914bc8 (diff)
Merge remote-tracking branch 'origin/5.14' into 5.15
Conflicts: src/imports/labsmodels/qqmltablemodel.cpp tests/auto/qml/qqmltablemodel/tst_qqmltablemodel.cpp This follows edc8512580fa16892dc13034e93300cc6a2bba59. Change-Id: I515d44d5d8309f4d7b911996c0ab65ea803176fa
Diffstat (limited to 'src/imports/labsmodels')
-rw-r--r--src/imports/labsmodels/qqmltablemodel.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/imports/labsmodels/qqmltablemodel.cpp b/src/imports/labsmodels/qqmltablemodel.cpp
index 6ba2cecf19..5a2d68780c 100644
--- a/src/imports/labsmodels/qqmltablemodel.cpp
+++ b/src/imports/labsmodels/qqmltablemodel.cpp
@@ -1043,11 +1043,24 @@ bool QQmlTableModel::validateNewRow(const char *functionName, const QVariant &ro
}
const QVariant rolePropertyValue = rowAsMap.value(roleData.name);
+
if (rolePropertyValue.userType() != 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;
+ }
}
}
}