summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJedrzej Nowacki <jedrzej.nowacki@nokia.com>2011-06-01 10:45:37 +0200
committerJedrzej Nowacki <jedrzej.nowacki@nokia.com>2011-06-15 14:24:37 +0200
commited2e9d619298c1eef94448b5d2adbc436ce246d6 (patch)
treed8609f99d686e55bf2489f4cc97e75b03c0a6d28
parent5cd9a11561ecb695df2dd6d9a441757ef358758d (diff)
downloadqtscript-ed2e9d619298c1eef94448b5d2adbc436ce246d6.tar.gz
Fix a persistent handle usage.
The QScriptValue created by custom user marshal function have to stay alive as long as we use internal handle. Normally QScriptValue destructor destroys internal handle which means that it is unusable.
-rw-r--r--src/script/api/qscriptengine.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp
index fbe9baa..aaa6136 100644
--- a/src/script/api/qscriptengine.cpp
+++ b/src/script/api/qscriptengine.cpp
@@ -227,7 +227,8 @@ v8::Handle<v8::Value> QScriptEnginePrivate::metaTypeToJS(int type, const void *d
v8::Handle<v8::Value> result;
TypeInfos::TypeInfo info = m_typeInfos.value(type);
if (info.marshal) {
- result = QScriptValuePrivate::get(info.marshal(q, data))->asV8Value(this);
+ QScriptValue userResult(info.marshal(q, data));
+ result = v8::Local<v8::Value>::New(QScriptValuePrivate::get(userResult)->asV8Value(this));
} else {
// check if it's one of the types we know
switch (QMetaType::Type(type)) {