aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4qobjectwrapper_p.h
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-05-23 16:11:50 +0200
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2016-05-24 14:00:39 +0200
commit8ae479a8eac7b9ffeeba24e9e459e3e02ca20587 (patch)
treed6fdf18ddd2456835c598f40399348d247af6c97 /src/qml/jsruntime/qv4qobjectwrapper_p.h
parent1337e0d0827e86591e67a6dbaaeb3bd3f9ed733b (diff)
parent607320ca9fb2796a5f6f2578578fd314f7e8b99e (diff)
Merge remote-tracking branch 'origin/5.7' into dev
Conflicts: src/qml/jsruntime/qv4engine_p.h src/qml/jsruntime/qv4runtime_p.h src/qml/qml/qqmldelayedcallqueue.cpp src/qml/qml/qqmlvaluetypewrapper.cpp src/qml/qml/qqmlvmemetaobject.cpp src/qml/qml/v8/qv8engine_p.h tests/auto/quick/qquicktext/tst_qquicktext.cpp Change-Id: I3f0608c7beb88088cbbef4d0db59920f56deaea9
Diffstat (limited to 'src/qml/jsruntime/qv4qobjectwrapper_p.h')
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper_p.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4qobjectwrapper_p.h b/src/qml/jsruntime/qv4qobjectwrapper_p.h
index 0186a8381a..d53bb88d20 100644
--- a/src/qml/jsruntime/qv4qobjectwrapper_p.h
+++ b/src/qml/jsruntime/qv4qobjectwrapper_p.h
@@ -146,8 +146,27 @@ protected:
static ReturnedValue method_connect(CallContext *ctx);
static ReturnedValue method_disconnect(CallContext *ctx);
+
+private:
+ static ReturnedValue wrap_slowPath(ExecutionEngine *engine, QObject *object);
};
+inline ReturnedValue QObjectWrapper::wrap(ExecutionEngine *engine, QObject *object)
+{
+ if (Q_LIKELY(!QQmlData::wasDeleted(object))) {
+ QObjectPrivate *priv = QObjectPrivate::get(const_cast<QObject *>(object));
+ if (Q_LIKELY(priv->declarativeData)) {
+ auto ddata = static_cast<QQmlData *>(priv->declarativeData);
+ if (Q_LIKELY(ddata->jsEngineId == engine->m_engineId && !ddata->jsWrapper.isUndefined())) {
+ // We own the JS object
+ return ddata->jsWrapper.value();
+ }
+ }
+ }
+
+ return wrap_slowPath(engine, object);
+}
+
struct QQmlValueTypeWrapper;
struct Q_QML_EXPORT QObjectMethod : public QV4::FunctionObject