From 2059f14faf2763810f90a73b89b963b39fc701a5 Mon Sep 17 00:00:00 2001 From: Marco Allegretti Date: Sat, 18 Apr 2026 19:04:40 +0200 Subject: [PATCH] Add null guards in AppletHost and TaskWidget MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit AppletHost: setPreloadFullRepresentation(true) does not guarantee fullRepresentationItem() is non-null on return — the applet loads asynchronously. Wire a single-shot connection to fullRepresentationItemChanged to emit appletReady() when the item arrives. TaskWidget: operationDescription() can return null for an unknown operation name; bail out rather than dereferencing it. --- components/mobileshell/components/applethost.cpp | 13 ++++++++++++- components/mobileshell/components/applethost.h | 3 +++ components/mobileshell/qml/statusbar/TaskWidget.qml | 3 +++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/components/mobileshell/components/applethost.cpp b/components/mobileshell/components/applethost.cpp index b2dff3b5..011fcf76 100644 --- a/components/mobileshell/components/applethost.cpp +++ b/components/mobileshell/components/applethost.cpp @@ -91,7 +91,18 @@ QQuickItem *AppletHost::fullRepresentationFor(const QString &pluginId) item->setPreloadFullRepresentation(true); - return item->fullRepresentationItem(); + auto *fullRepItem = item->fullRepresentationItem(); + if (!fullRepItem) { + connect( + item, + &PlasmaQuick::AppletQuickItem::fullRepresentationItemChanged, + this, + [this, pluginId]() { + Q_EMIT appletReady(pluginId); + }, + static_cast(Qt::AutoConnection | Qt::SingleShotConnection)); + } + return fullRepItem; } #include "applethost.moc" diff --git a/components/mobileshell/components/applethost.h b/components/mobileshell/components/applethost.h index a40898e3..9d152c3d 100644 --- a/components/mobileshell/components/applethost.h +++ b/components/mobileshell/components/applethost.h @@ -32,6 +32,9 @@ public: Q_INVOKABLE QQuickItem *fullRepresentationFor(const QString &pluginId); +Q_SIGNALS: + void appletReady(const QString &pluginId); + private: void ensureCorona(); diff --git a/components/mobileshell/qml/statusbar/TaskWidget.qml b/components/mobileshell/qml/statusbar/TaskWidget.qml index b4b24a5d..8c9056f5 100644 --- a/components/mobileshell/qml/statusbar/TaskWidget.qml +++ b/components/mobileshell/qml/statusbar/TaskWidget.qml @@ -50,6 +50,9 @@ Item { var operationName = mouse.button === Qt.RightButton ? "ContextMenu" : "Activate"; var operation = model.service.operationDescription(operationName); + if (!operation) { + return; + } operation.x = taskIcon.mapToGlobal(0, 0).x; operation.y = taskIcon.mapToGlobal(0, taskIcon.height).y; model.service.startOperationCall(operation);