diff options
author | Jedrzej Nowacki <jedrzej.nowacki@nokia.com> | 2009-08-19 14:26:58 (GMT) |
---|---|---|
committer | Jedrzej Nowacki <jedrzej.nowacki@nokia.com> | 2009-08-19 14:26:58 (GMT) |
commit | 7ae701ff4759bdfd12953c6f4d785c2d9241690f (patch) | |
tree | 7788e1119d5f5b3e620eb1b8e2a793ee6c828c8e /src | |
parent | bbf514474b2664779229b919b54b4c541157c1d3 (diff) | |
download | Qt-7ae701ff4759bdfd12953c6f4d785c2d9241690f.zip Qt-7ae701ff4759bdfd12953c6f4d785c2d9241690f.tar.gz Qt-7ae701ff4759bdfd12953c6f4d785c2d9241690f.tar.bz2 |
Fix QScriptValue::objectId().
QScriptValue id were made persistent. It depands
on JSC:JSValue JSCell pointer not on QScriptValuePrivate attr.
Reviewed-by: Kent Hansen
Diffstat (limited to 'src')
-rw-r--r-- | src/script/api/qscriptengine.cpp | 5 | ||||
-rw-r--r-- | src/script/api/qscriptengine_p.h | 2 | ||||
-rw-r--r-- | src/script/api/qscriptvalue.cpp | 4 | ||||
-rw-r--r-- | src/script/api/qscriptvalue_p.h | 9 |
4 files changed, 12 insertions, 8 deletions
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index 5ef07b9..3556c05 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -807,7 +807,7 @@ private: } // namespace QScript QScriptEnginePrivate::QScriptEnginePrivate() - : inEval(false), idGenerator(1) + : inEval(false) { qMetaTypeId<QScriptValue>(); @@ -1392,7 +1392,6 @@ bool QScriptEnginePrivate::scriptDisconnect(JSC::JSValue signal, JSC::JSValue re #endif void QScriptEnginePrivate::registerScriptValue(QScriptValuePrivate *value) { - value->id=idGenerator.fetchAndAddRelaxed(1); attachedScriptValues.insert(value); } @@ -3725,7 +3724,7 @@ QScriptValue QScriptEngine::objectById(qint64 id) const Q_D(const QScriptEngine); QSet<QScriptValuePrivate*>::const_iterator i = d->attachedScriptValues.constBegin(); while(i != d->attachedScriptValues.constEnd()) { - if ( (*i)->id == id ) + if ( (*i)->objectId() == id ) return QScriptValuePrivate::get(*i); i++; } diff --git a/src/script/api/qscriptengine_p.h b/src/script/api/qscriptengine_p.h index bc1dc92..64af653 100644 --- a/src/script/api/qscriptengine_p.h +++ b/src/script/api/qscriptengine_p.h @@ -250,8 +250,6 @@ public: QSet<QScriptValuePrivate*> attachedScriptValues; //keep trace to all QScriptValue evalueted - QAtomicInt idGenerator; //generate id for QScriptValue - #ifndef QT_NO_QOBJECT QHash<QObject*, QScript::QObjectData*> m_qobjectData; #endif diff --git a/src/script/api/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp index 7021cbc..edcb6ac 100644 --- a/src/script/api/qscriptvalue.cpp +++ b/src/script/api/qscriptvalue.cpp @@ -275,7 +275,7 @@ qsreal ToInteger(qsreal n) } // namespace QScript -QScriptValuePrivate::QScriptValuePrivate() : engine(this), valid(true), id(-1) +QScriptValuePrivate::QScriptValuePrivate() : engine(this), valid(true) { ref = 0; } @@ -2547,6 +2547,6 @@ void QScriptValue::setScriptClass(QScriptClass *scriptClass) */ qint64 QScriptValue::objectId() const { - return d_ptr?d_ptr->id:-1; + return d_ptr?d_ptr->objectId():-1; } QT_END_NAMESPACE diff --git a/src/script/api/qscriptvalue_p.h b/src/script/api/qscriptvalue_p.h index 43d48f3..7c1d538 100644 --- a/src/script/api/qscriptvalue_p.h +++ b/src/script/api/qscriptvalue_p.h @@ -148,6 +148,14 @@ public: engine=0; } + qint64 objectId() + { + if ( (type == JSC) && (valid) && (engine) ) + return (qint64)jscValue.asCell(); + else + return -1; + } + static void saveException(JSC::ExecState*, JSC::JSValue*); static void restoreException(JSC::ExecState*, JSC::JSValue); @@ -160,7 +168,6 @@ public: QBasicAtomicInt ref; bool valid; //object is valid ? - qint64 id; //object unique id number }; |