aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2023-02-03 10:14:56 +0100
committerUlf Hermann <ulf.hermann@qt.io>2023-02-07 19:23:13 +0100
commit11bc79d7c6e52dfb85e951e383f11395aecea337 (patch)
treeb2f721eadd284ecf69ac5af0d5ed6387d8a03dca /src/qml
parent7e51a3fd91f84937adaf45230ff105e2aabfcdbd (diff)
QML: Treat long and ulong like other numbers
They should either be the same size as int/uint or the same size as longlong/ulonglong, but for some reason we get them as separate types. Pick-to: 6.5 Fixes: QTBUG-110767 Change-Id: I4c5826cfe6108e6f9722e6b3443bde13b2141b04 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Semih Yavuz <semih.yavuz@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/qml')
-rw-r--r--src/qml/jsapi/qjsengine.cpp6
-rw-r--r--src/qml/jsruntime/qv4engine.cpp4
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper.cpp2
3 files changed, 12 insertions, 0 deletions
diff --git a/src/qml/jsapi/qjsengine.cpp b/src/qml/jsapi/qjsengine.cpp
index d3a6ed7391..86901c7955 100644
--- a/src/qml/jsapi/qjsengine.cpp
+++ b/src/qml/jsapi/qjsengine.cpp
@@ -872,6 +872,12 @@ bool QJSEngine::convertString(const QString &string, QMetaType metaType, void *p
case QMetaType::UInt:
*reinterpret_cast<uint*>(ptr) = QV4::Value::toUInt32(d);
return true;
+ case QMetaType::Long:
+ *reinterpret_cast<long*>(ptr) = QV4::Value::toInteger(d);
+ return true;
+ case QMetaType::ULong:
+ *reinterpret_cast<ulong*>(ptr) = QV4::Value::toInteger(d);
+ return true;
case QMetaType::LongLong:
*reinterpret_cast<qlonglong*>(ptr) = QV4::Value::toInteger(d);
return true;
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index 3d14d504e2..de0028826b 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -1758,6 +1758,10 @@ QV4::ReturnedValue ExecutionEngine::fromData(
return QV4::Encode(*reinterpret_cast<const int*>(ptr));
case QMetaType::UInt:
return QV4::Encode(*reinterpret_cast<const uint*>(ptr));
+ case QMetaType::Long:
+ return QV4::Encode((double)*reinterpret_cast<const long *>(ptr));
+ case QMetaType::ULong:
+ return QV4::Encode((double)*reinterpret_cast<const ulong *>(ptr));
case QMetaType::LongLong:
return QV4::Encode((double)*reinterpret_cast<const qlonglong*>(ptr));
case QMetaType::ULongLong:
diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp
index 4ef757b8e1..be44f1e8c2 100644
--- a/src/qml/qml/qqmlvaluetypewrapper.cpp
+++ b/src/qml/qml/qqmlvaluetypewrapper.cpp
@@ -383,6 +383,8 @@ static ReturnedValue getGadgetProperty(ExecutionEngine *engine,
VALUE_TYPE_LOAD(QMetaType::Bool, bool, bool);
VALUE_TYPE_LOAD(QMetaType::Int, int, int);
VALUE_TYPE_LOAD(QMetaType::UInt, uint, uint);
+ VALUE_TYPE_LOAD(QMetaType::Long, long, double);
+ VALUE_TYPE_LOAD(QMetaType::ULong, ulong, double);
VALUE_TYPE_LOAD(QMetaType::LongLong, qlonglong, double);
VALUE_TYPE_LOAD(QMetaType::ULongLong, qulonglong, double);
VALUE_TYPE_LOAD(QMetaType::Double, double, double);