From 65f09fa0124604ca6c07e6bf51600b69237940a6 Mon Sep 17 00:00:00 2001 From: Devin Lin Date: Wed, 19 Mar 2025 10:41:33 -0400 Subject: [PATCH] quicksettings/bluetooth: Add null checks Fixes: https://invent.kde.org/plasma/plasma-mobile/-/issues/434 Add null checks for when the bluetooth manager is null to avoid errors in the console. --- quicksettings/bluetooth/contents/ui/main.qml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/quicksettings/bluetooth/contents/ui/main.qml b/quicksettings/bluetooth/contents/ui/main.qml index 3b8728d9..9c4fc452 100644 --- a/quicksettings/bluetooth/contents/ui/main.qml +++ b/quicksettings/bluetooth/contents/ui/main.qml @@ -16,7 +16,12 @@ QS.QuickSetting { text: i18n("Bluetooth") icon: MobileShell.BluetoothInfo.icon settingsCommand: "plasma-open-settings kcm_bluetooth" + function toggle() { + if (!btManager) { + return; + } + const enable = !btManager.bluetoothOperational; btManager.bluetoothBlocked = !enable; @@ -24,7 +29,7 @@ QS.QuickSetting { btManager.adapters[i].powered = enable; } } - enabled: btManager.bluetoothOperational + enabled: btManager && btManager.bluetoothOperational Connections { target: btManager @@ -47,6 +52,10 @@ QS.QuickSetting { } function updateConnectedDevices() { + if (!btManager) { + return; + } + let _connectedDevices = []; for (let i = 0; i < btManager.devices.length; ++i) { const device = btManager.devices[i];