diff options
Diffstat (limited to 'src/qml')
-rw-r--r-- | src/qml/jit/qv4baselinejit.cpp | 1 | ||||
-rw-r--r-- | src/qml/jsapi/qjsvalue_p.h | 21 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4memberdata.cpp | 5 |
3 files changed, 22 insertions, 5 deletions
diff --git a/src/qml/jit/qv4baselinejit.cpp b/src/qml/jit/qv4baselinejit.cpp index 9dd2cdc43b..906cc30e67 100644 --- a/src/qml/jit/qv4baselinejit.cpp +++ b/src/qml/jit/qv4baselinejit.cpp @@ -897,7 +897,6 @@ void BaselineJIT::generate_ThrowOnNullOrUndefined() void BaselineJIT::generate_GetTemplateObject(int index) { - STORE_ACC(); as->prepareCallWithArgCount(2); as->passInt32AsArg(index, 1); as->passFunctionAsArg(0); diff --git a/src/qml/jsapi/qjsvalue_p.h b/src/qml/jsapi/qjsvalue_p.h index bcf0a9d12d..2faffffbae 100644 --- a/src/qml/jsapi/qjsvalue_p.h +++ b/src/qml/jsapi/qjsvalue_p.h @@ -60,6 +60,8 @@ #include <private/qv4mm_p.h> #include <private/qv4persistent_p.h> +#include <QtCore/qthread.h> + QT_BEGIN_NAMESPACE class Q_AUTOTEST_EXPORT QJSValuePrivate @@ -79,6 +81,11 @@ public: return nullptr; } + static inline void setRawValue(QJSValue *jsval, QV4::Value *v) + { + jsval->d = reinterpret_cast<quintptr>(v); + } + static inline void setVariant(QJSValue *jsval, const QVariant &v) { QVariant *val = new QVariant(v); jsval->d = reinterpret_cast<quintptr>(val) | 1; @@ -169,10 +176,20 @@ public: } static inline void free(QJSValue *jsval) { - if (QV4::Value *v = QJSValuePrivate::getValue(jsval)) + if (QV4::Value *v = QJSValuePrivate::getValue(jsval)) { + if (QV4::ExecutionEngine *e = engine(jsval)) { + if (QJSEngine *jsEngine = e->jsEngine()) { + if (jsEngine->thread() != QThread::currentThread()) { + QMetaObject::invokeMethod( + jsEngine, [v](){ QV4::PersistentValueStorage::free(v); }); + return; + } + } + } QV4::PersistentValueStorage::free(v); - else if (QVariant *v = QJSValuePrivate::getVariant(jsval)) + } else if (QVariant *v = QJSValuePrivate::getVariant(jsval)) { delete v; + } } }; diff --git a/src/qml/jsruntime/qv4memberdata.cpp b/src/qml/jsruntime/qv4memberdata.cpp index ffebe1b5da..34b0c38ae6 100644 --- a/src/qml/jsruntime/qv4memberdata.cpp +++ b/src/qml/jsruntime/qv4memberdata.cpp @@ -72,8 +72,9 @@ Heap::MemberData *MemberData::allocate(ExecutionEngine *e, uint n, Heap::MemberD // The above code can overflow in a number of interesting ways. All of those are unsigned, // and therefore defined behavior. Still, apply some sane bounds. - if (alloc > size_t(std::numeric_limits<int>::max())) - alloc = size_t(std::numeric_limits<int>::max()); + const size_t intMax = std::numeric_limits<int>::max(); + if (alloc > intMax) + alloc = intMax; Heap::MemberData *m; if (old) { |