aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/v8
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2011-06-08 14:32:39 +1000
committerAaron Kennedy <aaron.kennedy@nokia.com>2011-06-08 14:32:39 +1000
commit8902609a7e6cc27fceff15aa80547f1137efd7c9 (patch)
tree5cceabf2176d66260a4e6a600fbdf7c8f4002c80 /src/declarative/qml/v8
parent96cfe77fa311e60a2dfb7967d7ad6c06d40b99fb (diff)
Implement global handle tracking
This makes it easier to track down handles that have been double Dispose()'d. See qv8engine_p.h for details.
Diffstat (limited to 'src/declarative/qml/v8')
-rw-r--r--src/declarative/qml/v8/qv8contextwrapper.cpp8
-rw-r--r--src/declarative/qml/v8/qv8engine.cpp46
-rw-r--r--src/declarative/qml/v8/qv8engine_p.h49
-rw-r--r--src/declarative/qml/v8/qv8include.cpp10
-rw-r--r--src/declarative/qml/v8/qv8listwrapper.cpp4
-rw-r--r--src/declarative/qml/v8/qv8qobjectwrapper.cpp60
-rw-r--r--src/declarative/qml/v8/qv8typewrapper.cpp4
-rw-r--r--src/declarative/qml/v8/qv8valuetypewrapper.cpp4
-rw-r--r--src/declarative/qml/v8/qv8variantwrapper.cpp16
9 files changed, 139 insertions, 62 deletions
diff --git a/src/declarative/qml/v8/qv8contextwrapper.cpp b/src/declarative/qml/v8/qv8contextwrapper.cpp
index 1af4b4c883..27002c6dc0 100644
--- a/src/declarative/qml/v8/qv8contextwrapper.cpp
+++ b/src/declarative/qml/v8/qv8contextwrapper.cpp
@@ -123,8 +123,8 @@ QV8ContextWrapper::~QV8ContextWrapper()
void QV8ContextWrapper::destroy()
{
- m_urlConstructor.Dispose(); m_urlConstructor.Clear();
- m_constructor.Dispose(); m_constructor.Clear();
+ qPersistentDispose(m_urlConstructor);
+ qPersistentDispose(m_constructor);
}
void QV8ContextWrapper::init(QV8Engine *engine)
@@ -134,13 +134,13 @@ void QV8ContextWrapper::init(QV8Engine *engine)
v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
ft->InstanceTemplate()->SetHasExternalResource(true);
ft->InstanceTemplate()->SetFallbackPropertyHandler(Getter, Setter);
- m_constructor = v8::Persistent<v8::Function>::New(ft->GetFunction());
+ m_constructor = qPersistentNew<v8::Function>(ft->GetFunction());
}
{
v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
ft->InstanceTemplate()->SetHasExternalResource(true);
ft->InstanceTemplate()->SetFallbackPropertyHandler(NullGetter, NullSetter);
- m_urlConstructor = v8::Persistent<v8::Function>::New(ft->GetFunction());
+ m_urlConstructor = qPersistentNew<v8::Function>(ft->GetFunction());
}
}
diff --git a/src/declarative/qml/v8/qv8engine.cpp b/src/declarative/qml/v8/qv8engine.cpp
index 693c8aa952..530c9b0ef3 100644
--- a/src/declarative/qml/v8/qv8engine.cpp
+++ b/src/declarative/qml/v8/qv8engine.cpp
@@ -80,8 +80,7 @@ QV8Engine::~QV8Engine()
delete m_listModelData;
m_listModelData = 0;
- m_getOwnPropertyNames.Dispose(); m_getOwnPropertyNames.Clear();
-
+ qPersistentDispose(m_getOwnPropertyNames);
m_valueTypeWrapper.destroy();
m_variantWrapper.destroy();
m_listWrapper.destroy();
@@ -89,8 +88,7 @@ QV8Engine::~QV8Engine()
m_qobjectWrapper.destroy();
m_contextWrapper.destroy();
m_stringWrapper.destroy();
- m_context.Dispose();
- m_context.Clear();
+ qPersistentDispose(m_context);
}
void QV8Engine::init(QDeclarativeEngine *engine)
@@ -103,6 +101,7 @@ void QV8Engine::init(QDeclarativeEngine *engine)
v8::HandleScope handle_scope;
m_context = v8::Context::New();
+ qPersistentRegister(m_context);
v8::Context::Scope context_scope(m_context);
m_stringWrapper.init();
@@ -115,7 +114,7 @@ void QV8Engine::init(QDeclarativeEngine *engine)
{
v8::Handle<v8::Value> v = global()->Get(v8::String::New("Object"))->ToObject()->Get(v8::String::New("getOwnPropertyNames"));
- m_getOwnPropertyNames = v8::Persistent<v8::Function>::New(v8::Handle<v8::Function>::Cast(v));
+ m_getOwnPropertyNames = qPersistentNew<v8::Function>(v8::Handle<v8::Function>::Cast(v));
}
initializeGlobal(m_context->Global());
@@ -615,6 +614,43 @@ void QV8Engine::gc()
while (!v8::V8::IdleNotification()) {}
}
+#ifdef QML_GLOBAL_HANDLE_DEBUGGING
+#include <QtCore/qthreadstorage.h>
+static QThreadStorage<QSet<void *> *> QV8Engine_activeHandles;
+
+void QV8Engine::registerHandle(void *handle)
+{
+ if (!handle) {
+ qWarning("Attempting to register a null handle");
+ return;
+ }
+
+ if (!QV8Engine_activeHandles.hasLocalData())
+ QV8Engine_activeHandles.setLocalData(new QSet<void *>);
+
+ if (QV8Engine_activeHandles.localData()->contains(handle)) {
+ qFatal("Handle %p already alive", handle);
+ } else {
+ QV8Engine_activeHandles.localData()->insert(handle);
+ }
+}
+
+void QV8Engine::releaseHandle(void *handle)
+{
+ if (!handle)
+ return;
+
+ if (!QV8Engine_activeHandles.hasLocalData())
+ QV8Engine_activeHandles.setLocalData(new QSet<void *>);
+
+ if (QV8Engine_activeHandles.localData()->contains(handle)) {
+ QV8Engine_activeHandles.localData()->remove(handle);
+ } else {
+ qFatal("Handle %p already dead", handle);
+ }
+}
+#endif
+
v8::Handle<v8::Value> QV8Engine::gc(const v8::Arguments &args)
{
gc();
diff --git a/src/declarative/qml/v8/qv8engine_p.h b/src/declarative/qml/v8/qv8engine_p.h
index 5810b3e604..ee0b9115a3 100644
--- a/src/declarative/qml/v8/qv8engine_p.h
+++ b/src/declarative/qml/v8/qv8engine_p.h
@@ -70,6 +70,13 @@
QT_BEGIN_NAMESPACE
+
+// Uncomment the following line to enable global handle debugging. When enabled, all the persistent
+// handles allocated using qPersistentNew() (or registered with qPersistentRegsiter()) and disposed
+// with qPersistentDispose() are tracked. If you try and do something illegal, like double disposing
+// a handle, qFatal() is called.
+// #define QML_GLOBAL_HANDLE_DEBUGGING
+
#define V8_RESOURCE_TYPE(resourcetype) \
public: \
enum { V8ResourceType = QV8ObjectResource:: resourcetype }; \
@@ -240,6 +247,12 @@ public:
static void gc();
+#ifdef QML_GLOBAL_HANDLE_DEBUGGING
+ // Used for handle debugging
+ static void registerHandle(void *);
+ static void releaseHandle(void *);
+#endif
+
private:
QDeclarativeEngine *m_engine;
v8::Persistent<v8::Context> m_context;
@@ -294,6 +307,42 @@ private:
QDateTime qtDateTimeFromJsDate(double jsDate);
};
+// Allocate a new Persistent handle. *ALL* persistent handles in QML must be allocated
+// using this method.
+template<class T>
+v8::Persistent<T> qPersistentNew(v8::Handle<T> that)
+{
+ v8::Persistent<T> rv = v8::Persistent<T>::New(that);
+#ifdef QML_GLOBAL_HANDLE_DEBUGGING
+ QV8Engine::registerHandle(*rv);
+#endif
+ return rv;
+}
+
+// Register a Persistent handle that was returned to you by V8 (such as by
+// v8::Context::New). This allows us to do handle tracking on these handles too.
+template<class T>
+void qPersistentRegister(v8::Persistent<T> handle)
+{
+#ifdef QML_GLOBAL_HANDLE_DEBUGGING
+ QV8Engine::registerHandle(*handle);
+#else
+ Q_UNUSED(handle);
+#endif
+}
+
+// Dispose and clear a persistent handle. *ALL* persistent handles in QML must be
+// disposed using this method.
+template<class T>
+void qPersistentDispose(v8::Persistent<T> &that)
+{
+#ifdef QML_GLOBAL_HANDLE_DEBUGGING
+ QV8Engine::releaseHandle(*that);
+#endif
+ that.Dispose();
+ that.Clear();
+}
+
QString QV8Engine::toString(v8::Handle<v8::Value> string)
{
return m_stringWrapper.toString(string->ToString());
diff --git a/src/declarative/qml/v8/qv8include.cpp b/src/declarative/qml/v8/qv8include.cpp
index f2b25e0a92..3b8a081a3b 100644
--- a/src/declarative/qml/v8/qv8include.cpp
+++ b/src/declarative/qml/v8/qv8include.cpp
@@ -54,11 +54,11 @@ QV8Include::QV8Include(const QUrl &url, QV8Engine *engine, QDeclarativeContextDa
v8::Handle<v8::Object> qmlglobal, v8::Handle<v8::Function> callback)
: m_engine(engine), m_network(0), m_reply(0), m_url(url), m_redirectCount(0), m_context(context)
{
- m_qmlglobal = v8::Persistent<v8::Object>::New(qmlglobal);
+ m_qmlglobal = qPersistentNew<v8::Object>(qmlglobal);
if (!callback.IsEmpty())
- m_callbackFunction = v8::Persistent<v8::Function>::New(callback);
+ m_callbackFunction = qPersistentNew<v8::Function>(callback);
- m_resultObject = v8::Persistent<v8::Object>::New(resultValue());
+ m_resultObject = qPersistentNew<v8::Object>(resultValue());
m_network = engine->networkAccessManager();
@@ -72,8 +72,8 @@ QV8Include::QV8Include(const QUrl &url, QV8Engine *engine, QDeclarativeContextDa
QV8Include::~QV8Include()
{
delete m_reply; m_reply = 0;
- m_callbackFunction.Dispose();
- m_resultObject.Dispose();
+ qPersistentDispose(m_callbackFunction);
+ qPersistentDispose(m_resultObject);
}
v8::Local<v8::Object> QV8Include::resultValue(Status status)
diff --git a/src/declarative/qml/v8/qv8listwrapper.cpp b/src/declarative/qml/v8/qv8listwrapper.cpp
index 9e1110fd85..13b3b30c35 100644
--- a/src/declarative/qml/v8/qv8listwrapper.cpp
+++ b/src/declarative/qml/v8/qv8listwrapper.cpp
@@ -75,12 +75,12 @@ void QV8ListWrapper::init(QV8Engine *engine)
v8::Handle<v8::Value>(), v8::DEFAULT,
v8::PropertyAttribute(v8::ReadOnly | v8::DontDelete));
ft->InstanceTemplate()->SetHasExternalResource(true);
- m_constructor = v8::Persistent<v8::Function>::New(ft->GetFunction());
+ m_constructor = qPersistentNew<v8::Function>(ft->GetFunction());
}
void QV8ListWrapper::destroy()
{
- m_constructor.Dispose();
+ qPersistentDispose(m_constructor);
}
v8::Handle<v8::Value> QV8ListWrapper::newList(QObject *object, int propId, int propType)
diff --git a/src/declarative/qml/v8/qv8qobjectwrapper.cpp b/src/declarative/qml/v8/qv8qobjectwrapper.cpp
index 9ac482e003..75a97ac8b5 100644
--- a/src/declarative/qml/v8/qv8qobjectwrapper.cpp
+++ b/src/declarative/qml/v8/qv8qobjectwrapper.cpp
@@ -93,8 +93,7 @@ public:
~QV8QObjectInstance()
{
- v8object.Dispose();
- v8object.Clear();
+ qPersistentDispose(v8object);
}
virtual void objectDestroyed(QObject *o)
@@ -156,11 +155,11 @@ void QV8QObjectWrapper::destroy()
qDeleteAll(m_connections);
m_connections.clear();
- m_hiddenObject.Dispose(); m_hiddenObject.Clear();
- m_destroySymbol.Dispose(); m_destroySymbol.Clear();
- m_toStringSymbol.Dispose(); m_toStringSymbol.Clear();
- m_methodConstructor.Dispose(); m_methodConstructor.Clear();
- m_constructor.Dispose(); m_constructor.Clear();
+ qPersistentDispose(m_hiddenObject);
+ qPersistentDispose(m_destroySymbol);
+ qPersistentDispose(m_toStringSymbol);
+ qPersistentDispose(m_methodConstructor);
+ qPersistentDispose(m_constructor);
}
#define FAST_VALUE_GETTER(name, cpptype, defaultvalue, constructor) \
@@ -204,15 +203,15 @@ void QV8QObjectWrapper::init(QV8Engine *engine)
{
m_engine = engine;
- m_toStringSymbol = v8::Persistent<v8::String>::New(v8::String::NewSymbol("toString"));
- m_destroySymbol = v8::Persistent<v8::String>::New(v8::String::NewSymbol("destroy"));
- m_hiddenObject = v8::Persistent<v8::Object>::New(v8::Object::New());
+ m_toStringSymbol = qPersistentNew<v8::String>(v8::String::NewSymbol("toString"));
+ m_destroySymbol = qPersistentNew<v8::String>(v8::String::NewSymbol("destroy"));
+ m_hiddenObject = qPersistentNew<v8::Object>(v8::Object::New());
{
v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
ft->InstanceTemplate()->SetFallbackPropertyHandler(Getter, Setter, Query, 0, Enumerator);
ft->InstanceTemplate()->SetHasExternalResource(true);
- m_constructor = v8::Persistent<v8::Function>::New(ft->GetFunction());
+ m_constructor = qPersistentNew<v8::Function>(ft->GetFunction());
}
{
v8::ScriptOrigin origin(m_hiddenObject); // Hack to allow us to identify these functions
@@ -221,7 +220,7 @@ void QV8QObjectWrapper::init(QV8Engine *engine)
v8::Handle<v8::Value> invokeFn = v8::FunctionTemplate::New(Invoke)->GetFunction();
v8::Handle<v8::Value> args[] = { invokeFn };
v8::Local<v8::Function> createFn = v8::Local<v8::Function>::Cast(fn->Call(engine->global(), 1, args));
- m_methodConstructor = v8::Persistent<v8::Function>::New(createFn);
+ m_methodConstructor = qPersistentNew<v8::Function>(createFn);
}
{
@@ -656,15 +655,14 @@ static void WeakQObjectReferenceCallback(v8::Persistent<v8::Value> handle, void
}
}
- handle.Dispose();
+ qPersistentDispose(handle);
}
static void WeakQObjectInstanceCallback(v8::Persistent<v8::Value> handle, void *data)
{
QV8QObjectInstance *instance = (QV8QObjectInstance *)data;
instance->v8object.Clear();
- handle.Dispose();
- handle.Clear();
+ qPersistentDispose(handle);
}
v8::Local<v8::Object> QDeclarativePropertyCache::newQObject(QObject *object, QV8Engine *engine)
@@ -735,7 +733,7 @@ v8::Local<v8::Object> QDeclarativePropertyCache::newQObject(QObject *object, QV8
}
if (ft.IsEmpty()) {
- constructor = v8::Persistent<v8::Function>::New(engine->qobjectWrapper()->m_constructor);
+ constructor = qPersistentNew<v8::Function>(engine->qobjectWrapper()->m_constructor);
} else {
ft->InstanceTemplate()->SetFallbackPropertyHandler(QV8QObjectWrapper::Getter,
QV8QObjectWrapper::Setter,
@@ -743,7 +741,7 @@ v8::Local<v8::Object> QDeclarativePropertyCache::newQObject(QObject *object, QV8
0,
QV8QObjectWrapper::Enumerator);
ft->InstanceTemplate()->SetHasExternalResource(true);
- constructor = v8::Persistent<v8::Function>::New(ft->GetFunction());
+ constructor = qPersistentNew<v8::Function>(ft->GetFunction());
}
}
@@ -806,7 +804,7 @@ v8::Handle<v8::Value> QV8QObjectWrapper::newQObject(QObject *object)
!ddata->hasTaintedV8Object)) { // Someone else has used the QObject, but it isn't tainted
v8::Local<v8::Object> rv = newQObject(object, ddata, m_engine);
- ddata->v8object = v8::Persistent<v8::Object>::New(rv);
+ ddata->v8object = qPersistentNew<v8::Object>(rv);
ddata->v8object.MakeWeak(0, WeakQObjectReferenceCallback);
ddata->v8objectid = m_id;
return rv;
@@ -822,7 +820,7 @@ v8::Handle<v8::Value> QV8QObjectWrapper::newQObject(QObject *object)
// a handle in the ddata, we can assume ownership of the ddata->v8object
if ((!found || (*iter)->v8object.IsEmpty()) && ddata->v8object.IsEmpty()) {
v8::Local<v8::Object> rv = newQObject(object, ddata, m_engine);
- ddata->v8object = v8::Persistent<v8::Object>::New(rv);
+ ddata->v8object = qPersistentNew<v8::Object>(rv);
ddata->v8object.MakeWeak(0, WeakQObjectReferenceCallback);
ddata->v8objectid = m_id;
@@ -840,7 +838,7 @@ v8::Handle<v8::Value> QV8QObjectWrapper::newQObject(QObject *object)
if ((*iter)->v8object.IsEmpty()) {
v8::Local<v8::Object> rv = newQObject(object, ddata, m_engine);
- (*iter)->v8object = v8::Persistent<v8::Object>::New(rv);
+ (*iter)->v8object = qPersistentNew<v8::Object>(rv);
(*iter)->v8object.MakeWeak((*iter), WeakQObjectInstanceCallback);
}
@@ -897,10 +895,8 @@ QV8QObjectConnectionList::~QV8QObjectConnectionList()
for (SlotHash::Iterator iter = slotHash.begin(); iter != slotHash.end(); ++iter) {
QList<Connection> &connections = *iter;
for (int ii = 0; ii < connections.count(); ++ii) {
- connections[ii].thisObject.Dispose();
- connections[ii].function.Dispose();
- connections[ii].thisObject.Clear();
- connections[ii].function.Clear();
+ qPersistentDispose(connections[ii].thisObject);
+ qPersistentDispose(connections[ii].function);
}
}
slotHash.clear();
@@ -1010,8 +1006,8 @@ v8::Handle<v8::Value> QV8QObjectWrapper::Connect(const v8::Arguments &args)
QV8QObjectConnectionList::Connection connection;
if (!functionThisValue.IsEmpty())
- connection.thisObject = v8::Persistent<v8::Object>::New(functionThisValue->ToObject());
- connection.function = v8::Persistent<v8::Function>::New(v8::Handle<v8::Function>::Cast(functionValue));
+ connection.thisObject = qPersistentNew<v8::Object>(functionThisValue->ToObject());
+ connection.function = qPersistentNew<v8::Function>(v8::Handle<v8::Function>::Cast(functionValue));
slotIter->append(connection);
@@ -1084,10 +1080,8 @@ v8::Handle<v8::Value> QV8QObjectWrapper::Disconnect(const v8::Arguments &args)
QPair<QObject *, int> connectedFunctionData = ExtractQtMethod(engine, connection.function);
if (connectedFunctionData == functionData) {
// Match!
- connection.thisObject.Dispose();
- connection.function.Dispose();
- connection.thisObject.Clear();
- connection.function.Clear();
+ qPersistentDispose(connection.thisObject);
+ qPersistentDispose(connection.function);
connections.removeAt(ii);
return v8::Undefined();
}
@@ -1102,10 +1096,8 @@ v8::Handle<v8::Value> QV8QObjectWrapper::Disconnect(const v8::Arguments &args)
connection.thisObject.IsEmpty() == functionThisValue.IsEmpty() &&
(connection.thisObject.IsEmpty() || connection.thisObject->StrictEquals(functionThisValue))) {
// Match!
- connection.thisObject.Dispose();
- connection.function.Dispose();
- connection.thisObject.Clear();
- connection.function.Clear();
+ qPersistentDispose(connection.thisObject);
+ qPersistentDispose(connection.function);
connections.removeAt(ii);
return v8::Undefined();
}
diff --git a/src/declarative/qml/v8/qv8typewrapper.cpp b/src/declarative/qml/v8/qv8typewrapper.cpp
index 2067f73fae..b4a510e2be 100644
--- a/src/declarative/qml/v8/qv8typewrapper.cpp
+++ b/src/declarative/qml/v8/qv8typewrapper.cpp
@@ -83,7 +83,7 @@ QV8TypeWrapper::~QV8TypeWrapper()
void QV8TypeWrapper::destroy()
{
- m_constructor.Dispose();
+ qPersistentDispose(m_constructor);
}
void QV8TypeWrapper::init(QV8Engine *engine)
@@ -92,7 +92,7 @@ void QV8TypeWrapper::init(QV8Engine *engine)
v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
ft->InstanceTemplate()->SetNamedPropertyHandler(Getter, Setter);
ft->InstanceTemplate()->SetHasExternalResource(true);
- m_constructor = v8::Persistent<v8::Function>::New(ft->GetFunction());
+ m_constructor = qPersistentNew<v8::Function>(ft->GetFunction());
}
v8::Local<v8::Object> QV8TypeWrapper::newObject(QObject *o, QDeclarativeType *t, TypeNameMode mode)
diff --git a/src/declarative/qml/v8/qv8valuetypewrapper.cpp b/src/declarative/qml/v8/qv8valuetypewrapper.cpp
index 6dfb4312bc..b16a81e607 100644
--- a/src/declarative/qml/v8/qv8valuetypewrapper.cpp
+++ b/src/declarative/qml/v8/qv8valuetypewrapper.cpp
@@ -103,7 +103,7 @@ QV8ValueTypeWrapper::~QV8ValueTypeWrapper()
void QV8ValueTypeWrapper::destroy()
{
- m_constructor.Dispose();
+ qPersistentDispose(m_constructor);
}
void QV8ValueTypeWrapper::init(QV8Engine *engine)
@@ -112,7 +112,7 @@ void QV8ValueTypeWrapper::init(QV8Engine *engine)
v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
ft->InstanceTemplate()->SetNamedPropertyHandler(Getter, Setter);
ft->InstanceTemplate()->SetHasExternalResource(true);
- m_constructor = v8::Persistent<v8::Function>::New(ft->GetFunction());
+ m_constructor = qPersistentNew<v8::Function>(ft->GetFunction());
}
v8::Local<v8::Object> QV8ValueTypeWrapper::newValueType(QObject *object, int property, QDeclarativeValueType *type)
diff --git a/src/declarative/qml/v8/qv8variantwrapper.cpp b/src/declarative/qml/v8/qv8variantwrapper.cpp
index de3cb11926..ef1f972ad1 100644
--- a/src/declarative/qml/v8/qv8variantwrapper.cpp
+++ b/src/declarative/qml/v8/qv8variantwrapper.cpp
@@ -74,11 +74,11 @@ void QV8VariantWrapper::init(QV8Engine *engine)
v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
ft->InstanceTemplate()->SetNamedPropertyHandler(Getter, Setter);
ft->InstanceTemplate()->SetHasExternalResource(true);
- m_constructor = v8::Persistent<v8::Function>::New(ft->GetFunction());
+ m_constructor = qPersistentNew<v8::Function>(ft->GetFunction());
}
{
- m_preserve = v8::Persistent<v8::Function>::New(v8::FunctionTemplate::New(Preserve)->GetFunction());
- m_destroy = v8::Persistent<v8::Function>::New(v8::FunctionTemplate::New(Destroy)->GetFunction());
+ m_preserve = qPersistentNew<v8::Function>(v8::FunctionTemplate::New(Preserve)->GetFunction());
+ m_destroy = qPersistentNew<v8::Function>(v8::FunctionTemplate::New(Destroy)->GetFunction());
v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
ft->InstanceTemplate()->SetFallbackPropertyHandler(Getter, Setter);
ft->InstanceTemplate()->SetHasExternalResource(true);
@@ -88,17 +88,17 @@ void QV8VariantWrapper::init(QV8Engine *engine)
ft->InstanceTemplate()->SetAccessor(v8::String::New("destroy"), DestroyGetter, 0,
m_destroy, v8::DEFAULT,
v8::PropertyAttribute(v8::ReadOnly | v8::DontDelete));
- m_scarceConstructor = v8::Persistent<v8::Function>::New(ft->GetFunction());
+ m_scarceConstructor = qPersistentNew<v8::Function>(ft->GetFunction());
}
}
void QV8VariantWrapper::destroy()
{
- m_destroy.Dispose(); m_destroy.Clear();
- m_preserve.Dispose(); m_preserve.Clear();
- m_scarceConstructor.Dispose(); m_scarceConstructor.Clear();
- m_constructor.Dispose(); m_constructor.Clear();
+ qPersistentDispose(m_destroy);
+ qPersistentDispose(m_preserve);
+ qPersistentDispose(m_scarceConstructor);
+ qPersistentDispose(m_constructor);
}
v8::Local<v8::Object> QV8VariantWrapper::newVariant(const QVariant &value)