getJSValue() has been fixed

This commit is contained in:
Arin Alex 2019-01-27 00:09:43 +03:00
parent 0d0ba64bac
commit dd5c1f6ca0
2 changed files with 4 additions and 2 deletions

View File

@ -156,7 +156,8 @@ namespace Const{
template <typename T> template <typename T>
static inline QJSValue getJSValue(QJSEngine &e, T *p) static inline QJSValue getJSValue(QJSEngine &e, T *p)
{ {
QJSValue res = e.toScriptValue(p); QJSValue res = e.newQObject(p);
QQmlEngine::setObjectOwnership(p, QQmlEngine::CppOwnership);
return res; return res;
} }
#else #else

View File

@ -156,7 +156,8 @@ namespace Const{
template <typename T> template <typename T>
static inline QJSValue getJSValue(QJSEngine &e, T *p) static inline QJSValue getJSValue(QJSEngine &e, T *p)
{ {
QJSValue res = e.toScriptValue(p); QJSValue res = e.newQObject(p);
QQmlEngine::setObjectOwnership(p, QQmlEngine::CppOwnership);
return res; return res;
} }
#else #else