From 8fecdf1d2d59f825d8c71160a39840d03732db22 Mon Sep 17 00:00:00 2001 From: Marco Allegretti Date: Sat, 18 Apr 2026 20:24:11 +0200 Subject: [PATCH] Guard against invalid KPackage in AppletHost loadPackage + setPath can produce an invalid package if the shell package is missing. Guard with isValid() to avoid passing a bad package to setKPackage. Add the QML_SINGLETON factory that the QML engine requires for proper singleton instantiation. --- components/mobileshell/components/applethost.cpp | 4 ++++ components/mobileshell/components/applethost.h | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/components/mobileshell/components/applethost.cpp b/components/mobileshell/components/applethost.cpp index 011fcf76..9fe7cf16 100644 --- a/components/mobileshell/components/applethost.cpp +++ b/components/mobileshell/components/applethost.cpp @@ -25,6 +25,10 @@ public: { KPackage::Package pkg = KPackage::PackageLoader::self()->loadPackage(u"Plasma/Shell"_s); pkg.setPath(u"org.kde.plasma.mobile"_s); + if (!pkg.isValid()) { + qWarning() << "AppletHost: failed to load plasma shell package org.kde.plasma.mobile"; + return; + } setKPackage(pkg); } diff --git a/components/mobileshell/components/applethost.h b/components/mobileshell/components/applethost.h index 9d152c3d..0b686ccd 100644 --- a/components/mobileshell/components/applethost.h +++ b/components/mobileshell/components/applethost.h @@ -30,6 +30,11 @@ public: explicit AppletHost(QObject *parent = nullptr); ~AppletHost() override; + static QObject *create(QQmlEngine * /*engine*/, QJSEngine * /*scriptEngine*/) + { + return new AppletHost(); + } + Q_INVOKABLE QQuickItem *fullRepresentationFor(const QString &pluginId); Q_SIGNALS: