summaryrefslogtreecommitdiffstats
path: root/src/libs/installer/scriptengine.cpp
diff options
context:
space:
mode:
authorKatja Marttila <katja.marttila@qt.io>2023-05-25 11:17:02 +0300
committerKatja Marttila <katja.marttila@qt.io>2023-06-12 11:56:35 +0300
commitc6a06cd0a9aef990b57772f4caaf1aa8832ccee0 (patch)
treeea364178fc5e53a727284d6493163057e91419c7 /src/libs/installer/scriptengine.cpp
parent70081ce03cac6c331ed471a7f0ab6b38b843e31e (diff)
Omit thisObject creation in javascript code
Originally, new Component object was created for javascript so that the garbage collector would not destroy the object. This caused the thisObject in javascript to differ from the object in packageManagerCore, which in Qt6.5 lead to warning messages when each script was evaluated: "Warning: :1: Calling C++ methods with 'this' objects different from the one they were retrieved from is broken, due to historical reasons. The original object is used as 'this' object." Fixes so that the new object creation is omitted and QJSEngine::CppOwnership is set to Component object so that garbage collector won't destroy it. Task-number: QTIFW-1829 Change-Id: Ia131d88fc83122f11c5b19a431e7db45e0ba18f9 Reviewed-by: Arttu Tarkiainen <arttu.tarkiainen@qt.io>
Diffstat (limited to 'src/libs/installer/scriptengine.cpp')
-rw-r--r--src/libs/installer/scriptengine.cpp36
1 files changed, 0 insertions, 36 deletions
diff --git a/src/libs/installer/scriptengine.cpp b/src/libs/installer/scriptengine.cpp
index 4bce74991..602f88b61 100644
--- a/src/libs/installer/scriptengine.cpp
+++ b/src/libs/installer/scriptengine.cpp
@@ -56,12 +56,6 @@ namespace QInstaller {
/*!
\inmodule QtInstallerFramework
- \class QInstaller::InstallerProxy
- \internal
-*/
-
-/*!
- \inmodule QtInstallerFramework
\class QInstaller::QDesktopServicesProxy
\internal
*/
@@ -72,28 +66,6 @@ namespace QInstaller {
\internal
*/
-QJSValue InstallerProxy::components(const QString &regexp) const
-{
- if (m_core) {
- const QList<Component*> all = m_core->components(PackageManagerCore::ComponentType::All, regexp);
- QJSValue scriptComponentsObject = m_engine->newArray(all.count());
- for (int i = 0; i < all.count(); ++i) {
- Component *const component = all.at(i);
- QQmlEngine::setObjectOwnership(component, QQmlEngine::CppOwnership);
- scriptComponentsObject.setProperty(i, m_engine->newQObject(component));
- }
- return scriptComponentsObject;
- }
- return m_engine->newArray();
-}
-
-QJSValue InstallerProxy::componentByName(const QString &componentName)
-{
- if (m_core)
- return m_engine->newQObject(m_core->componentByName(componentName), false);
- return QJSValue();
-}
-
QJSValue QDesktopServicesProxy::findFiles(const QString &path, const QString &pattern)
{
QStringList result;
@@ -380,9 +352,6 @@ ScriptEngine::ScriptEngine(PackageManagerCore *core) : QObject(core)
QJSValue global = m_engine.globalObject();
global.setProperty(QLatin1String("QFileDialog"), m_engine.newQObject(new QFileDialogProxy(core)));
- const QJSValue proxy = m_engine.newQObject(new InstallerProxy(this, core));
- global.setProperty(QLatin1String("InstallerProxy"), proxy);
-
global.setProperty(QLatin1String("systemInfo"), m_engine.newQObject(new SystemInfo));
global.setProperty(QLatin1String("QInstaller"), generateQInstallerObject());
@@ -402,11 +371,6 @@ ScriptEngine::ScriptEngine(PackageManagerCore *core) : QObject(core)
global.setProperty(QLatin1String("installer"), m_engine.newQObject(new QObject));
}
global.setProperty(QLatin1String("gui"), m_engine.newQObject(m_guiProxy));
-
- global.property(QLatin1String("installer")).setProperty(QLatin1String("components"),
- proxy.property(QLatin1String("components")));
- global.property(QLatin1String("installer")).setProperty(QLatin1String("componentByName"),
- proxy.property(QLatin1String("componentByName")));
}
/*!