mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
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.
This commit is contained in:
parent
013d034516
commit
65f09fa012
1 changed files with 10 additions and 1 deletions
|
|
@ -16,7 +16,12 @@ QS.QuickSetting {
|
||||||
text: i18n("Bluetooth")
|
text: i18n("Bluetooth")
|
||||||
icon: MobileShell.BluetoothInfo.icon
|
icon: MobileShell.BluetoothInfo.icon
|
||||||
settingsCommand: "plasma-open-settings kcm_bluetooth"
|
settingsCommand: "plasma-open-settings kcm_bluetooth"
|
||||||
|
|
||||||
function toggle() {
|
function toggle() {
|
||||||
|
if (!btManager) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const enable = !btManager.bluetoothOperational;
|
const enable = !btManager.bluetoothOperational;
|
||||||
btManager.bluetoothBlocked = !enable;
|
btManager.bluetoothBlocked = !enable;
|
||||||
|
|
||||||
|
|
@ -24,7 +29,7 @@ QS.QuickSetting {
|
||||||
btManager.adapters[i].powered = enable;
|
btManager.adapters[i].powered = enable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
enabled: btManager.bluetoothOperational
|
enabled: btManager && btManager.bluetoothOperational
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: btManager
|
target: btManager
|
||||||
|
|
@ -47,6 +52,10 @@ QS.QuickSetting {
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateConnectedDevices() {
|
function updateConnectedDevices() {
|
||||||
|
if (!btManager) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let _connectedDevices = [];
|
let _connectedDevices = [];
|
||||||
for (let i = 0; i < btManager.devices.length; ++i) {
|
for (let i = 0; i < btManager.devices.length; ++i) {
|
||||||
const device = btManager.devices[i];
|
const device = btManager.devices[i];
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue