aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/v8/qv8engine_p.h
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2011-12-13 17:18:45 +0100
committerQt by Nokia <qt-info@nokia.com>2011-12-15 13:42:29 +0100
commitd70cca804e88110eae32f92baff7cee957a6a531 (patch)
treefa2dc18d907095c8bb953e249cfc2dd379b5bd9c /src/declarative/qml/v8/qv8engine_p.h
parent9ae39c98f43a29e3f68a1f34469c9ad2551f813c (diff)
V8: Remove extra V8::Context allocated for expressing strong references
Moved the Referencer code into QV8Engine and re-used the available v8 context there. That also makes things a bit cleaner in the sense that now references from one object to another are guaranteed to be within the same context. Previously some strong references would be across contexts that do not actually share a security token. Change-Id: I717b27a4d96323feb570023d4d84f2b2176d1a84 Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com> Reviewed-by: Chris Adams <christopher.adams@nokia.com>
Diffstat (limited to 'src/declarative/qml/v8/qv8engine_p.h')
-rw-r--r--src/declarative/qml/v8/qv8engine_p.h24
1 files changed, 8 insertions, 16 deletions
diff --git a/src/declarative/qml/v8/qv8engine_p.h b/src/declarative/qml/v8/qv8engine_p.h
index 4e6d3de91f..7564a699bb 100644
--- a/src/declarative/qml/v8/qv8engine_p.h
+++ b/src/declarative/qml/v8/qv8engine_p.h
@@ -231,23 +231,9 @@ public:
static void garbageCollectorPrologueCallback(v8::GCType, v8::GCCallbackFlags);
static void registerGcPrologueCallback();
- class Q_AUTOTEST_EXPORT Referencer {
- public:
- ~Referencer();
- void addRelationship(QObject *object, v8::Persistent<v8::Value> handle);
- void addRelationship(QObject *object, QObject *other);
- void dispose();
- private:
- Referencer();
- static v8::Persistent<v8::Object> *findOwnerAndStrength(QObject *qobjectOwner, bool *shouldBeStrong);
- v8::Persistent<v8::Object> strongReferencer;
- v8::Persistent<v8::Context> context;
- friend class QV8GCCallback;
- };
-
class Q_AUTOTEST_EXPORT Node {
public:
- typedef void (*PrologueCallback)(Referencer *r, Node *node);
+ typedef void (*PrologueCallback)(Node *node);
Node(PrologueCallback callback);
~Node();
@@ -451,11 +437,13 @@ public:
static QDateTime qtDateTimeFromJsDate(double jsDate);
+ void addRelationshipForGC(QObject *object, v8::Persistent<v8::Value> handle);
+ void addRelationshipForGC(QObject *object, QObject *other);
+
struct ThreadData {
ThreadData();
~ThreadData();
v8::Isolate* isolate;
- QV8GCCallback::Referencer* referencer;
bool gcPrologueCallbackRegistered;
QIntrusiveList<QV8GCCallback::Node, &QV8GCCallback::Node::node> gcCallbackNodes;
};
@@ -464,6 +452,8 @@ public:
static ThreadData* threadData();
static void ensurePerThreadIsolate();
+ v8::Persistent<v8::Object> m_strongReferencer;
+
protected:
QJSEngine* q;
QDeclarativeEngine *m_engine;
@@ -503,6 +493,8 @@ protected:
double qtDateTimeToJsDate(const QDateTime &dt);
private:
+ static v8::Persistent<v8::Object> *findOwnerAndStrength(QObject *object, bool *shouldBeStrong);
+
typedef QScriptIntrusiveList<QJSValuePrivate, &QJSValuePrivate::m_node> ValueList;
ValueList m_values;
typedef QScriptIntrusiveList<QJSValueIteratorPrivate, &QJSValueIteratorPrivate::m_node> ValueIteratorList;