[PATCH] applets/systemmonitor: handle null faceController
authorChristoph Wolk <cwo.kde@posteo.net>
Tue, 25 Mar 2025 09:46:10 +0000 (10:46 +0100)
committerAurélien COUDERC <coucouf@debian.org>
Tue, 20 May 2025 06:31:26 +0000 (08:31 +0200)
When initially adding a systemmonitor widget to a panel, faceController
can still be null, causing several TypeErrors.

Instead, use optional chaining and default values to prevent these
errors until the faceController is loaded.

Gbp-Pq: Name upstream_d4df9b5f_applets-systemmonitor-handle-null-faceController.patch

applets/systemmonitor/systemmonitor/package/contents/ui/main.qml

index f41f11d3ddcfcee15f0a8b7947361648181cd06d..6d4480cae8a0ee9070ee5419be4a925619c6fbe0 100644 (file)
@@ -59,7 +59,7 @@ PlasmoidItem {
 
     preferredRepresentation: Plasmoid.formFactor === PlasmaCore.Types.Planar ? fullRepresentation : null
 
-    Plasmoid.title: Plasmoid.faceController.title || i18n("System Monitor")
+    Plasmoid.title: Plasmoid.faceController?.title || i18n("System Monitor")
     toolTipSubText: totalSensor.sensorId ? i18nc("Sensor name: value", "%1: %2", totalSensor.name, totalSensor.formattedValue) : ""
 
     compactRepresentation: CompactRepresentation {
@@ -67,12 +67,12 @@ PlasmoidItem {
     fullRepresentation: FullRepresentation {
     }
 
-    Plasmoid.configurationRequired: Plasmoid.faceController.highPrioritySensorIds.length == 0 && Plasmoid.faceController.lowPrioritySensorIds.length == 0 && Plasmoid.faceController.totalSensors.length == 0
+    Plasmoid.configurationRequired: (Plasmoid.faceController ?? false) && Plasmoid.faceController.highPrioritySensorIds.length == 0 && Plasmoid.faceController.lowPrioritySensorIds.length == 0 && Plasmoid.faceController.totalSensors.length == 0
 
     Sensors.Sensor {
         id: totalSensor
-        sensorId: Plasmoid.faceController.totalSensors[0] || ""
-        updateRateLimit: Plasmoid.faceController.updateRateLimit
+        sensorId: Plasmoid.faceController?.totalSensors[0] || ""
+        updateRateLimit: Plasmoid.faceController?.updateRateLimit
     }
 
     MouseArea {