aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/v8
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-06-21 15:19:20 +0200
committerLars Knoll <lars.knoll@digia.com>2013-06-21 16:09:36 +0200
commitdaa2c41906bb7580fa0b160b5ff7fe900043c823 (patch)
treeb081176355640c2301930037f4ad3206f5f65aa4 /src/qml/qml/v8
parent4041464b00fb1358ed2f92949ff76f3b39bdc700 (diff)
Fix tst_qjsvalue::engineDeleted()
Move the engine pointer from QJSValuePrivate to PersistentValuePrivate and set it back to null in the memory manager destructor. Change-Id: I904b365221e1559701353cb359eac768928ad918 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/qml/v8')
-rw-r--r--src/qml/qml/v8/qjsengine.cpp3
-rw-r--r--src/qml/qml/v8/qjsvalue.cpp44
-rw-r--r--src/qml/qml/v8/qjsvalue_p.h23
3 files changed, 24 insertions, 46 deletions
diff --git a/src/qml/qml/v8/qjsengine.cpp b/src/qml/qml/v8/qjsengine.cpp
index 9a3b7f200c..24d46277e9 100644
--- a/src/qml/qml/v8/qjsengine.cpp
+++ b/src/qml/qml/v8/qjsengine.cpp
@@ -356,8 +356,7 @@ QJSValue QJSEngine::create(int type, const void *ptr)
bool QJSEngine::convertV2(const QJSValue &value, int type, void *ptr)
{
QJSValuePrivate *vp = QJSValuePrivate::get(value);
- QV4::ExecutionEngine *e = vp->engine();
- QV8Engine *engine = e ? e->v8Engine : 0;
+ QV8Engine *engine = vp->engine ? vp->engine->v8Engine : 0;
if (engine) {
return engine->metaTypeFromJS(vp->getValue(engine->m_v4Engine), type, ptr);
} else {
diff --git a/src/qml/qml/v8/qjsvalue.cpp b/src/qml/qml/v8/qjsvalue.cpp
index 38975b0df6..f3563a7a1d 100644
--- a/src/qml/qml/v8/qjsvalue.cpp
+++ b/src/qml/qml/v8/qjsvalue.cpp
@@ -57,15 +57,15 @@
QV4::Value QJSValuePrivate::getValue(QV4::ExecutionEngine *e)
{
- if (!this->e)
- this->e = e;
- else if (this->e != e) {
+ if (!this->engine)
+ this->engine = e;
+ else if (this->engine != e) {
qWarning("JSValue can't be reassigned to another engine.");
return QV4::Value::emptyValue();
}
if (value.asString() == &string) {
- value = QV4::Value::fromString(e->newString(string.toQString()));
- PersistentValuePrivate **listRoot = &e->memoryManager->m_persistentValues;
+ value = QV4::Value::fromString(engine->newString(string.toQString()));
+ PersistentValuePrivate **listRoot = &engine->memoryManager->m_persistentValues;
prev = listRoot;
next = *listRoot;
*prev = this;
@@ -375,8 +375,7 @@ QString QJSValue::toString() const
*/
double QJSValue::toNumber() const
{
- QV4::ExecutionEngine *e = d->engine();
- QV4::ExecutionContext *ctx = e ? e->current : 0;
+ QV4::ExecutionContext *ctx = d->engine ? d->engine->current : 0;
try {
return d->value.toNumber();
} catch (Exception &e) {
@@ -399,8 +398,7 @@ double QJSValue::toNumber() const
*/
bool QJSValue::toBool() const
{
- QV4::ExecutionEngine *e = d->engine();
- QV4::ExecutionContext *ctx = e ? e->current : 0;
+ QV4::ExecutionContext *ctx = d->engine ? d->engine->current : 0;
try {
return d->value.toBoolean();
} catch (Exception &e) {
@@ -423,8 +421,7 @@ bool QJSValue::toBool() const
*/
qint32 QJSValue::toInt() const
{
- QV4::ExecutionEngine *e = d->engine();
- QV4::ExecutionContext *ctx = e ? e->current : 0;
+ QV4::ExecutionContext *ctx = d->engine ? d->engine->current : 0;
try {
return d->value.toInt32();
} catch (Exception &e) {
@@ -447,8 +444,7 @@ qint32 QJSValue::toInt() const
*/
quint32 QJSValue::toUInt() const
{
- QV4::ExecutionEngine *e = d->engine();
- QV4::ExecutionContext *ctx = e ? e->current : 0;
+ QV4::ExecutionContext *ctx = d->engine ? d->engine->current : 0;
try {
return d->value.toUInt32();
} catch (Exception &e) {
@@ -505,7 +501,7 @@ QJSValue QJSValue::call(const QJSValueList &args)
if (!f)
return QJSValue();
- ExecutionEngine *engine = d->engine();
+ ExecutionEngine *engine = d->engine;
assert(engine);
QVarLengthArray<Value, 9> arguments(args.length());
@@ -555,7 +551,7 @@ QJSValue QJSValue::callWithInstance(const QJSValue &instance, const QJSValueList
if (!f)
return QJSValue();
- ExecutionEngine *engine = d->engine();
+ ExecutionEngine *engine = d->engine;
assert(engine);
if (!instance.d->checkEngine(engine)) {
@@ -608,7 +604,7 @@ QJSValue QJSValue::callAsConstructor(const QJSValueList &args)
if (!f)
return QJSValue();
- ExecutionEngine *engine = d->engine();
+ ExecutionEngine *engine = d->engine;
assert(engine);
QVarLengthArray<Value, 9> arguments(args.length());
@@ -643,7 +639,7 @@ QJSValue QJSValue::callAsConstructor(const QJSValueList &args)
*/
QJSEngine* QJSValue::engine() const
{
- QV4::ExecutionEngine *engine = d->engine();
+ QV4::ExecutionEngine *engine = d->engine;
if (engine)
return engine->v8Engine->publicEngine();
}
@@ -798,7 +794,7 @@ QJSValue QJSValue::property(const QString& name) const
if (!o)
return QJSValue();
- ExecutionEngine *engine = d->engine();
+ ExecutionEngine *engine = d->engine;
String *s = engine->newString(name);
uint idx = s->asArrayIndex();
if (idx < UINT_MAX)
@@ -833,7 +829,7 @@ QJSValue QJSValue::property(quint32 arrayIndex) const
if (!o)
return QJSValue();
- ExecutionEngine *engine = d->engine();
+ ExecutionEngine *engine = d->engine;
QV4::ExecutionContext *ctx = engine->current;
try {
QV4::Value v = arrayIndex == UINT_MAX ? o->get(ctx, engine->id_uintMax) : o->getIndexed(ctx, arrayIndex);
@@ -866,7 +862,7 @@ void QJSValue::setProperty(const QString& name, const QJSValue& value)
return;
}
- ExecutionEngine *engine = d->engine();
+ ExecutionEngine *engine = d->engine;
String *s = engine->newString(name);
uint idx = s->asArrayIndex();
if (idx < UINT_MAX) {
@@ -901,7 +897,7 @@ void QJSValue::setProperty(quint32 arrayIndex, const QJSValue& value)
if (!o)
return;
- ExecutionEngine *engine = d->engine();
+ ExecutionEngine *engine = d->engine;
QV4::ExecutionContext *ctx = engine->current;
try {
if (arrayIndex != UINT_MAX)
@@ -939,7 +935,7 @@ bool QJSValue::deleteProperty(const QString &name)
if (!o)
return false;
- ExecutionEngine *engine = d->engine();
+ ExecutionEngine *engine = d->engine;
String *s = engine->newString(name);
return o->deleteProperty(engine->current, s);
}
@@ -956,7 +952,7 @@ bool QJSValue::hasProperty(const QString &name) const
if (!o)
return false;
- ExecutionEngine *engine = d->engine();
+ ExecutionEngine *engine = d->engine;
String *s = engine->newIdentifier(name);
return o->__hasProperty__(s);
}
@@ -973,7 +969,7 @@ bool QJSValue::hasOwnProperty(const QString &name) const
if (!o)
return false;
- ExecutionEngine *engine = d->engine();
+ ExecutionEngine *engine = d->engine;
String *s = engine->newIdentifier(name);
return o->__getOwnProperty__(s);
}
diff --git a/src/qml/qml/v8/qjsvalue_p.h b/src/qml/qml/v8/qjsvalue_p.h
index a1cd471785..ef94dea555 100644
--- a/src/qml/qml/v8/qjsvalue_p.h
+++ b/src/qml/qml/v8/qjsvalue_p.h
@@ -69,46 +69,29 @@ class QJSValuePrivate : public QV4::PersistentValuePrivate
{
public:
QJSValuePrivate(QV4::ExecutionEngine *engine, const QV4::Value &v)
- : PersistentValuePrivate(v)
- , e(engine)
+ : PersistentValuePrivate(v, engine)
{
if (value.isEmpty())
value = QV4::Value::undefinedValue();
}
QJSValuePrivate(QV4::Object *o)
: PersistentValuePrivate(QV4::Value::fromObject(o))
- { e = o->engine(); }
+ { }
QJSValuePrivate(QV4::String *s)
: PersistentValuePrivate(QV4::Value::fromString(s))
- { e = s->engine(); }
+ { }
QJSValuePrivate(const QString &s)
: PersistentValuePrivate(QV4::Value::undefinedValue())
, string(0, s)
- , e(0)
{
value = QV4::Value::fromString(&string);
}
QV4::Value getValue(QV4::ExecutionEngine *e);
- bool checkEngine(QV4::ExecutionEngine *otherEngine) {
- if (!e) {
- assert(!value.isObject());
- e = otherEngine;
- }
- return (e == otherEngine);
- }
-
- QV4::ExecutionEngine *engine() const {
- if (!e)
- e = value.engine();
- return e;
- }
-
static QJSValuePrivate *get(const QJSValue &v) { return v.d; }
QV4::String string;
- mutable QV4::ExecutionEngine *e;
};
QT_END_NAMESPACE