mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
Add null guards in AppletHost and TaskWidget
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.
This commit is contained in:
parent
76e027f630
commit
2059f14faf
3 changed files with 18 additions and 1 deletions
|
|
@ -91,7 +91,18 @@ QQuickItem *AppletHost::fullRepresentationFor(const QString &pluginId)
|
||||||
|
|
||||||
item->setPreloadFullRepresentation(true);
|
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::ConnectionType>(Qt::AutoConnection | Qt::SingleShotConnection));
|
||||||
|
}
|
||||||
|
return fullRepItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "applethost.moc"
|
#include "applethost.moc"
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,9 @@ public:
|
||||||
|
|
||||||
Q_INVOKABLE QQuickItem *fullRepresentationFor(const QString &pluginId);
|
Q_INVOKABLE QQuickItem *fullRepresentationFor(const QString &pluginId);
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void appletReady(const QString &pluginId);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ensureCorona();
|
void ensureCorona();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,9 @@ Item {
|
||||||
|
|
||||||
var operationName = mouse.button === Qt.RightButton ? "ContextMenu" : "Activate";
|
var operationName = mouse.button === Qt.RightButton ? "ContextMenu" : "Activate";
|
||||||
var operation = model.service.operationDescription(operationName);
|
var operation = model.service.operationDescription(operationName);
|
||||||
|
if (!operation) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
operation.x = taskIcon.mapToGlobal(0, 0).x;
|
operation.x = taskIcon.mapToGlobal(0, 0).x;
|
||||||
operation.y = taskIcon.mapToGlobal(0, taskIcon.height).y;
|
operation.y = taskIcon.mapToGlobal(0, taskIcon.height).y;
|
||||||
model.service.startOperationCall(operation);
|
model.service.startOperationCall(operation);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue