summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/libs/installer/scriptengine.cpp12
-rw-r--r--src/libs/installer/scriptengine_p.h15
2 files changed, 16 insertions, 11 deletions
diff --git a/src/libs/installer/scriptengine.cpp b/src/libs/installer/scriptengine.cpp
index 0d41e812d..6d776db88 100644
--- a/src/libs/installer/scriptengine.cpp
+++ b/src/libs/installer/scriptengine.cpp
@@ -294,6 +294,13 @@ namespace QInstaller {
\qmlsignal gui::settingsButtonClicked();
*/
+QJSValue InstallerProxy::componentByName(const QString &componentName)
+{
+ if (m_core)
+ return m_engine->newQObject(m_core->componentByName(componentName));
+ return QJSValue();
+}
+
GuiProxy::GuiProxy(ScriptEngine *engine, QObject *parent) :
QObject(parent),
m_engine(engine),
@@ -503,7 +510,7 @@ ScriptEngine::ScriptEngine(PackageManagerCore *core) :
QJSValue global = m_engine.globalObject();
global.setProperty(QLatin1String("console"), m_engine.newQObject(new ConsoleProxy));
global.setProperty(QLatin1String("QFileDialog"), m_engine.newQObject(new QFileDialogProxy));
- const QJSValue proxy = m_engine.newQObject(new InstallerProxy(&m_engine, core));
+ const QJSValue proxy = m_engine.newQObject(new InstallerProxy(this, core));
global.setProperty(QLatin1String("InstallerProxy"), proxy);
global.setProperty(QLatin1String("print"), m_engine.newQObject(new ConsoleProxy)
.property(QLatin1String("log")));
@@ -558,6 +565,9 @@ ScriptEngine::ScriptEngine(PackageManagerCore *core) :
QJSValue ScriptEngine::newQObject(QObject *object)
{
QJSValue jsValue = m_engine.newQObject(object);
+ if (!jsValue.isQObject())
+ return jsValue;
+
QQmlEngine::setObjectOwnership(object, QQmlEngine::CppOwnership);
// add findChild(), findChildren() methods known from QtScript
diff --git a/src/libs/installer/scriptengine_p.h b/src/libs/installer/scriptengine_p.h
index 696073703..eeb547a78 100644
--- a/src/libs/installer/scriptengine_p.h
+++ b/src/libs/installer/scriptengine_p.h
@@ -1,6 +1,6 @@
/**************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Installer Framework.
@@ -42,7 +42,6 @@
#include <QDebug>
#include <QDesktopServices>
#include <QFileDialog>
-#include <QJSEngine>
#include <QStandardPaths>
namespace QInstaller {
@@ -65,18 +64,14 @@ class InstallerProxy : public QObject
Q_DISABLE_COPY(InstallerProxy)
public:
- InstallerProxy(QJSEngine *engine, PackageManagerCore *core)
+ InstallerProxy(ScriptEngine *engine, PackageManagerCore *core)
: m_engine(engine), m_core(core) {}
-public slots :
- QJSValue componentByName(const QString &componentName) {
- if (m_core)
- return m_engine->newQObject(m_core->componentByName(componentName));
- return QJSValue();
- }
+public slots:
+ QJSValue componentByName(const QString &componentName);
private:
- QJSEngine *m_engine;
+ ScriptEngine *m_engine;
PackageManagerCore *m_core;
};