diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-09-24 14:28:02 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-26 09:05:25 +0200 |
commit | 9062476491dd1c81f63bb7a3ae6e6a080db1db1e (patch) | |
tree | 362935aece4c4c4fd62f15ef14b61c048bcc514c /src/qml/qml/v8 | |
parent | 0f204625dc6720d40df22ca352af995af5448525 (diff) |
Make parts of qv8engine_p.h GC safe
Change-Id: Iaa15423cedc307a09b3cd7287272d93d7a604caf
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/qml/v8')
-rw-r--r-- | src/qml/qml/v8/qv8engine.cpp | 14 | ||||
-rw-r--r-- | src/qml/qml/v8/qv8engine_p.h | 7 |
2 files changed, 11 insertions, 10 deletions
diff --git a/src/qml/qml/v8/qv8engine.cpp b/src/qml/qml/v8/qv8engine.cpp index e8c84eee35..40b512bdc7 100644 --- a/src/qml/qml/v8/qv8engine.cpp +++ b/src/qml/qml/v8/qv8engine.cpp @@ -459,7 +459,7 @@ void QV8Engine::initializeGlobal() } } -void QV8Engine::freezeObject(const QV4::Value &value) +void QV8Engine::freezeObject(const QV4::ValueRef value) { QV4::Scope scope(m_v4Engine); QV4::ScopedFunctionObject f(scope, m_freezeObject.value()); @@ -507,7 +507,9 @@ void QV8Engine::setExtensionData(int index, Deletable *data) void QV8Engine::initQmlGlobalObject() { initializeGlobal(); - freezeObject(QV4::Value::fromObject(m_v4Engine->globalObject)); + QV4::Scope scope(m_v4Engine); + QV4::ScopedValue v(scope, m_v4Engine->globalObject); + freezeObject(v); } void QV8Engine::setEngine(QQmlEngine *engine) @@ -516,9 +518,9 @@ void QV8Engine::setEngine(QQmlEngine *engine) initQmlGlobalObject(); } -QV4::Value QV8Engine::global() +QV4::ReturnedValue QV8Engine::global() { - return QV4::Value::fromObject(m_v4Engine->globalObject); + return m_v4Engine->globalObject->asReturnedValue(); } // Converts a QVariantList to JS. @@ -992,9 +994,9 @@ int QV8Engine::consoleCountHelper(const QString &file, quint16 line, quint16 col return number; } -QV4::Value QV8Engine::toString(const QString &string) +QV4::ReturnedValue QV8Engine::toString(const QString &string) { - return QV4::Value::fromString(m_v4Engine->newString(string)); + return QV4::Value::fromString(m_v4Engine->newString(string)).asReturnedValue(); } QT_END_NAMESPACE diff --git a/src/qml/qml/v8/qv8engine_p.h b/src/qml/qml/v8/qv8engine_p.h index d7490036f3..e27be50f29 100644 --- a/src/qml/qml/v8/qv8engine_p.h +++ b/src/qml/qml/v8/qv8engine_p.h @@ -194,7 +194,7 @@ public: void setEngine(QQmlEngine *engine); QQmlEngine *engine() { return m_engine; } QJSEngine *publicEngine() { return q; } - QV4::Value global(); + QV4::ReturnedValue global(); void *xmlHttpRequestData() { return m_xmlHttpRequestData; } @@ -203,13 +203,13 @@ public: QQmlContextData *callingContext(); - void freezeObject(const QV4::Value &value); + void freezeObject(const QV4::ValueRef value); QVariant toVariant(const QV4::Value &value, int typeHint); QV4::ReturnedValue fromVariant(const QVariant &); // Return a JS string for the given QString \a string - QV4::Value toString(const QString &string); + QV4::ReturnedValue toString(const QString &string); // Return the network access manager for this engine. By default this returns the network // access manager of the QQmlEngine. It is overridden in the case of a threaded v8 @@ -219,7 +219,6 @@ public: // Return the list of illegal id names (the names of the properties on the global object) const QV4::IdentifierHash<bool> &illegalNames() const; - inline void collectGarbage() { gc(); } void gc(); static QMutex *registrationMutex(); |