aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/labsmodels
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2020-04-24 01:00:22 +0200
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2020-04-24 01:00:23 +0200
commit03bfdc5425c22ed7a0aa2f901e965813fe0753d0 (patch)
tree8c5ad0347ce376e1d45903addccc149a1d90bfaa /src/imports/labsmodels
parent9fd4160307ab54b89d0145ebde0a91d293fa95a5 (diff)
parent7c9a54907f44b7e30ceac1975edcfa7920ffafd8 (diff)
Merge remote-tracking branch 'origin/5.15' into dev
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;
+ }
}
}
}