mirror of
https://github.com/huderlem/porymap.git
synced 2026-03-21 17:45:44 -05:00
Disable new conversion error for Qt5
Some checks failed
Build Porymap / build-linux (, 5.14.2) (push) Has been cancelled
Build Porymap / build-linux (, 6.8.*) (push) Has been cancelled
Build Porymap / build-linux (minimal, 5.14.2) (push) Has been cancelled
Build Porymap / build-macos (macos-15-intel) (push) Has been cancelled
Build Porymap / build-macos (macos-latest) (push) Has been cancelled
Build Porymap / build-static-windows (push) Has been cancelled
Some checks failed
Build Porymap / build-linux (, 5.14.2) (push) Has been cancelled
Build Porymap / build-linux (, 6.8.*) (push) Has been cancelled
Build Porymap / build-linux (minimal, 5.14.2) (push) Has been cancelled
Build Porymap / build-macos (macos-15-intel) (push) Has been cancelled
Build Porymap / build-macos (macos-latest) (push) Has been cancelled
Build Porymap / build-static-windows (push) Has been cancelled
This commit is contained in:
parent
37769cf931
commit
386b608504
|
|
@ -70,13 +70,17 @@ struct DefaultConverter {
|
|||
if (!v.canConvert<T>()) {
|
||||
if (errors) errors->append(QString("Can't convert from JSON to type '%1'").arg(v.typeName()));
|
||||
} else {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
// 'canConvert' is only true if a conversion between types is theoretically possible,
|
||||
// not necessarily if this value can be converted. e.g. "2" can be converted to int (2),
|
||||
// but "hello world" cannot be converted to int and becomes 0.
|
||||
// For older versions of Qt, we rely on QVariant::value.
|
||||
|
||||
T value;
|
||||
bool ok = QMetaType::convert(v.metaType(), v.constData(), QMetaType::fromType<T>(), &value);
|
||||
if (ok) return value;
|
||||
else if (errors) errors->append(QString("Failed to convert JSON value to type '%1'").arg(v.typeName()));
|
||||
#endif
|
||||
}
|
||||
// For failed conversion, return a default constructed value.
|
||||
return v.value<T>();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user