Commit 3088c972 authored by Tobias Hunger's avatar Tobias Hunger

Core: Have the JsExpander take ownership of registered QObjects

Change-Id: Ice5f232d5d7bed32b23f6713b7fa44f44a3ea502
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent 57cc2727
......@@ -44,11 +44,10 @@ namespace Internal {
class JsExpanderPrivate {
public:
JsExpanderPrivate() : m_utilsExtension(new UtilsJsExtension) { }
~JsExpanderPrivate() { delete m_utilsExtension; }
~JsExpanderPrivate() { qDeleteAll(m_registeredObjects); }
QScriptEngine m_engine;
UtilsJsExtension *m_utilsExtension;
QList<QObject *> m_registeredObjects;
};
} // namespace Internal
......@@ -57,6 +56,7 @@ static Internal::JsExpanderPrivate *d;
void JsExpander::registerQObjectForJs(const QString &name, QObject *obj)
{
d->m_registeredObjects.append(obj);
QScriptValue jsObj = d->m_engine.newQObject(obj, QScriptEngine::QtOwnership);
d->m_engine.globalObject().setProperty(name, jsObj);
}
......@@ -104,7 +104,7 @@ JsExpander::JsExpander()
}
});
registerQObjectForJs(QLatin1String("Util"), d->m_utilsExtension);
registerQObjectForJs(QLatin1String("Util"), new Internal::UtilsJsExtension);
}
JsExpander::~JsExpander()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment