diff options
author | Lars Knoll <lars.knoll@theqtcompany.com> | 2015-04-28 18:02:23 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2015-06-15 17:03:37 +0000 |
commit | a9021009ab295d89e210821693c7f5bd733ccc35 (patch) | |
tree | dc0b8ab48ce256ef5e640a8c5a47f68688d9eecb /src/qml/jsruntime/qv4jsonobject_p.h | |
parent | 73093cbe4b0a6bf61da0280ee8df9a07fbcc38c7 (diff) |
Fix GC problem with json conversion methods
The ObjectSet used to protect against recursion is not safe
against a GC that moves objects around. Fix this by storing
pointers to QV4::Object in there instead.
Change-Id: I88bcac330246a1c9180caed13be1f6ab5c40a6ae
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/qml/jsruntime/qv4jsonobject_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4jsonobject_p.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/qml/jsruntime/qv4jsonobject_p.h b/src/qml/jsruntime/qv4jsonobject_p.h index dbb49cb592..1ad0e2c5de 100644 --- a/src/qml/jsruntime/qv4jsonobject_p.h +++ b/src/qml/jsruntime/qv4jsonobject_p.h @@ -38,6 +38,7 @@ #include <qjsonobject.h> #include <qjsonvalue.h> #include <qjsondocument.h> +#include <qhash.h> QT_BEGIN_NAMESPACE @@ -51,12 +52,23 @@ struct JsonObject : Object { } +struct ObjectItem { + const QV4::Object *o; + ObjectItem(const QV4::Object *o) : o(o) {} +}; + +inline bool operator ==(const ObjectItem &a, const ObjectItem &b) +{ return a.o->d() == b.o->d(); } + +inline int qHash(const ObjectItem &i, uint seed = 0) +{ return ::qHash((void *)i.o->d(), seed); } + struct JsonObject : Object { Q_MANAGED_TYPE(JsonObject) V4_OBJECT2(JsonObject, Object) private: - // ### GC - typedef QSet<QV4::Heap::Base *> V4ObjectSet; + + typedef QSet<ObjectItem> V4ObjectSet; public: static ReturnedValue method_parse(CallContext *ctx); |