diff options
Diffstat (limited to 'src/script/api/qscriptvalue.cpp')
-rw-r--r-- | src/script/api/qscriptvalue.cpp | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/script/api/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp index bcbc3f7..b1e70b5 100644 --- a/src/script/api/qscriptvalue.cpp +++ b/src/script/api/qscriptvalue.cpp @@ -243,7 +243,7 @@ qsreal ToInteger(qsreal n) } // namespace QScript -QScriptValuePrivate::QScriptValuePrivate() +QScriptValuePrivate::QScriptValuePrivate() : engine(this), valid(true) { ref = 0; } @@ -252,6 +252,28 @@ QScriptValuePrivate::~QScriptValuePrivate() { } +QScriptValuePrivate::QScriptValueAutoRegister::QScriptValueAutoRegister(QScriptValuePrivate *value,const QScriptEngine *engine): + val(value), ptr(const_cast<QScriptEngine*>(engine)) +{ + QScriptEnginePrivate::get(ptr)->registerScriptValue(val); +} + +QScriptValuePrivate::QScriptValueAutoRegister::~QScriptValueAutoRegister() +{ + if (ptr) QScriptEnginePrivate::get(ptr)->unregisterScriptValue(val); +} + +QScriptValuePrivate::QScriptValueAutoRegister& QScriptValuePrivate::QScriptValueAutoRegister::operator=(const QScriptEngine *pointer) +{ + if (ptr) + QScriptEnginePrivate::get(ptr)->unregisterScriptValue(val); + ptr = const_cast<QScriptEngine*> (pointer); + if (ptr) + QScriptEnginePrivate::get(ptr)->registerScriptValue(val); + return *this; +}; + + void QScriptValuePrivate::initFromJSCValue(JSC::JSValue value) { type = JSC; @@ -2270,7 +2292,10 @@ bool QScriptValue::isQMetaObject() const bool QScriptValue::isValid() const { Q_D(const QScriptValue); - return (d != 0); + if (d) + return d->isValid(); + else + return false; } /*! |