Fix undefined property accesses

Adds a check for root.currentDevice before accessing its properties
This commit is contained in:
Karthik Nishanth 2023-08-23 23:32:24 -07:00 committed by Aleix Pol Gonzalez
parent 1bebc3bc5d
commit f42bb35346

View file

@ -21,12 +21,12 @@ Kirigami.ScrollablePage {
icon.name: "network-disconnect" icon.name: "network-disconnect"
onTriggered: root.currentDevice.unpair() onTriggered: root.currentDevice.unpair()
text: i18nd("kdeconnect-app", "Unpair") text: i18nd("kdeconnect-app", "Unpair")
visible: root.currentDevice.isPaired visible: root.currentDevice && root.currentDevice.isPaired
}, },
Kirigami.Action { Kirigami.Action {
icon.name: "hands-free" icon.name: "hands-free"
text: i18nd("kdeconnect-app", "Send Ping") text: i18nd("kdeconnect-app", "Send Ping")
visible: root.currentDevice.isPaired && root.currentDevice.isReachable visible: root.currentDevice && root.currentDevice.isPaired && root.currentDevice.isReachable
onTriggered: { onTriggered: {
root.currentDevice.pluginCall("ping", "sendPing"); root.currentDevice.pluginCall("ping", "sendPing");
} }
@ -34,7 +34,7 @@ Kirigami.ScrollablePage {
Kirigami.Action { Kirigami.Action {
icon.name: "settings-configure" icon.name: "settings-configure"
text: i18n("Plugin Settings") text: i18n("Plugin Settings")
visible: root.currentDevice.isPaired && root.currentDevice.isReachable visible: root.currentDevice && root.currentDevice.isPaired && root.currentDevice.isReachable
onTriggered: { onTriggered: {
pageStack.push( pageStack.push(
Qt.resolvedUrl("PluginSettings.qml"), Qt.resolvedUrl("PluginSettings.qml"),