aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4qobjectwrapper_p.h
diff options
context:
space:
mode:
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