From 50d80a50cf122057acaa5773cae7f675982b3577 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 8 May 2013 07:30:42 +0200 Subject: [PATCH] Convert qv8include to QV4::PersistentValue Change-Id: I9764ad7d28932bd67e3d284415c26f1b3b837056 Reviewed-by: Simon Hausmann --- src/qml/qml/v8/qv8include.cpp | 24 +++++++++++------------- src/qml/qml/v8/qv8include_p.h | 8 +++++--- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/qml/qml/v8/qv8include.cpp b/src/qml/qml/v8/qv8include.cpp index 72b7868..9794d85 100644 --- a/src/qml/qml/v8/qv8include.cpp +++ b/src/qml/qml/v8/qv8include.cpp @@ -56,11 +56,11 @@ QV8Include::QV8Include(const QUrl &url, QV8Engine *engine, QQmlContextData *cont v8::Handle qmlglobal, v8::Handle callback) : m_engine(engine), m_network(0), m_reply(0), m_url(url), m_redirectCount(0), m_context(context) { - m_qmlglobal = qPersistentNew(qmlglobal); + m_qmlglobal = qmlglobal->v4Value(); if (!callback.IsEmpty()) - m_callbackFunction = qPersistentNew(callback); + m_callbackFunction = callback->v4Value(); - m_resultObject = qPersistentNew(resultValue()); + m_resultObject = resultValue()->v4Value(); m_network = engine->networkAccessManager(); @@ -74,8 +74,6 @@ QV8Include::QV8Include(const QUrl &url, QV8Engine *engine, QQmlContextData *cont QV8Include::~QV8Include() { delete m_reply; m_reply = 0; - qPersistentDispose(m_callbackFunction); - qPersistentDispose(m_resultObject); } v8::Handle QV8Include::resultValue(Status status) @@ -103,7 +101,7 @@ void QV8Include::callback(QV8Engine *engine, v8::Handle callback, v8::Handle QV8Include::result() { - return m_resultObject; + return m_resultObject.value(); } #define INCLUDE_MAXIMUM_REDIRECT_RECURSION 15 @@ -144,21 +142,21 @@ void QV8Include::finished() v8::Handle script = m_engine->qmlModeCompile(code, m_url.toString()); if (!try_catch.HasCaught()) { - m_engine->contextWrapper()->addSubContext(m_qmlglobal, script, importContext); - script->Run(m_qmlglobal); + m_engine->contextWrapper()->addSubContext(m_qmlglobal.value(), script, importContext); + script->Run(m_qmlglobal.value()); } if (try_catch.HasCaught()) { - m_resultObject->Set(v8::String::New("status"), v8::Integer::New(Exception)); - m_resultObject->Set(v8::String::New("exception"), try_catch.Exception()); + v8::Handle(m_resultObject)->Set(v8::String::New("status"), v8::Integer::New(Exception)); + v8::Handle(m_resultObject)->Set(v8::String::New("exception"), try_catch.Exception()); } else { - m_resultObject->Set(v8::String::New("status"), v8::Integer::New(Ok)); + v8::Handle(m_resultObject)->Set(v8::String::New("status"), v8::Integer::New(Ok)); } } else { - m_resultObject->Set(v8::String::New("status"), v8::Integer::New(NetworkError)); + v8::Handle(m_resultObject)->Set(v8::String::New("status"), v8::Integer::New(NetworkError)); } - callback(m_engine, m_callbackFunction, m_resultObject); + callback(m_engine, m_callbackFunction.value(), m_resultObject.value()); disconnect(); deleteLater(); diff --git a/src/qml/qml/v8/qv8include_p.h b/src/qml/qml/v8/qv8include_p.h index ab7b2ff..c7118c2 100644 --- a/src/qml/qml/v8/qv8include_p.h +++ b/src/qml/qml/v8/qv8include_p.h @@ -61,6 +61,8 @@ #include +#include + QT_BEGIN_NAMESPACE class QQmlEngine; @@ -100,11 +102,11 @@ private: QUrl m_url; int m_redirectCount; - v8::Persistent m_callbackFunction; - v8::Persistent m_resultObject; + QV4::PersistentValue m_callbackFunction; + QV4::PersistentValue m_resultObject; QQmlGuardedContextData m_context; - v8::Persistent m_qmlglobal; + QV4::PersistentValue m_qmlglobal; }; QT_END_NAMESPACE -- 2.7.4