From 0798c6facb509655f136450230e74d99a08a11df Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 8 May 2013 07:31:04 +0200 Subject: [PATCH] Convert qv8listwrapper to use QV4::PersistentValue Change-Id: I1a85ae5ca0f4688174cda6127a326aed51f64b1b Reviewed-by: Simon Hausmann --- src/qml/qml/v8/qv8listwrapper.cpp | 9 +++++---- src/qml/qml/v8/qv8listwrapper_p.h | 4 +++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/qml/qml/v8/qv8listwrapper.cpp b/src/qml/qml/v8/qv8listwrapper.cpp index 8dc3576..c2e821d 100644 --- a/src/qml/qml/v8/qv8listwrapper.cpp +++ b/src/qml/qml/v8/qv8listwrapper.cpp @@ -43,6 +43,8 @@ #include "qv8engine_p.h" #include +#include + QT_BEGIN_NAMESPACE class QV8ListResource : public QV8ObjectResource @@ -75,12 +77,11 @@ void QV8ListWrapper::init(QV8Engine *engine) v8::Handle(), v8::DEFAULT, v8::PropertyAttribute(v8::ReadOnly | v8::DontDelete | v8::DontEnum)); ft->InstanceTemplate()->SetHasExternalResource(true); - m_constructor = qPersistentNew(ft->GetFunction()); + m_constructor = ft->GetFunction()->v4Value(); } void QV8ListWrapper::destroy() { - qPersistentDispose(m_constructor); } v8::Handle QV8ListWrapper::newList(QObject *object, int propId, int propType) @@ -89,7 +90,7 @@ v8::Handle QV8ListWrapper::newList(QObject *object, int propId, int p return QV4::Value::nullValue(); // XXX NewInstance() should be optimized - v8::Handle rv = m_constructor->NewInstance(); + v8::Handle rv = m_constructor.value().asFunctionObject()->newInstance(); QV8ListResource *r = new QV8ListResource(m_engine); r->object = object; r->propertyType = propType; @@ -102,7 +103,7 @@ v8::Handle QV8ListWrapper::newList(QObject *object, int propId, int p v8::Handle QV8ListWrapper::newList(const QQmlListProperty &prop, int propType) { // XXX NewInstance() should be optimized - v8::Handle rv = m_constructor->NewInstance(); + v8::Handle rv = m_constructor.value().asFunctionObject()->newInstance(); QV8ListResource *r = new QV8ListResource(m_engine); r->object = prop.object; r->property = prop; diff --git a/src/qml/qml/v8/qv8listwrapper_p.h b/src/qml/qml/v8/qv8listwrapper_p.h index e2ec535..8031a3b 100644 --- a/src/qml/qml/v8/qv8listwrapper_p.h +++ b/src/qml/qml/v8/qv8listwrapper_p.h @@ -57,6 +57,8 @@ #include #include +#include + QT_BEGIN_NAMESPACE class QV8Engine; @@ -88,7 +90,7 @@ private: static v8::Handle Enumerator(const v8::AccessorInfo &info); QV8Engine *m_engine; - v8::Persistent m_constructor; + QV4::PersistentValue m_constructor; }; QT_END_NAMESPACE -- 2.7.4