network: don't assume NMActiveConnection has a device

In practice this has been seen to fail:

    JS ERROR: TypeError: active.get_devices(...)[0] is undefined
    ensureActiveConnectionProps@resource:///org/gnome/shell/ui/status/network.js:73:22
    _getMainConnection@resource:///org/gnome/shell/ui/status/network.js:1791:13
    _syncMainConnection@resource:///org/gnome/shell/ui/status/network.js:1809:32

https://gitlab.gnome.org/GNOME/gnome-shell/issues/1406
This commit is contained in:
Will Thompson 2019-06-21 10:47:40 +01:00
parent ccf646f54a
commit 94ba52af0c
No known key found for this signature in database
GPG Key ID: 3422DC0D7AD482A7

View File

@ -69,9 +69,12 @@ function ssidToLabel(ssid) {
function ensureActiveConnectionProps(active, client) {
if (!active._primaryDevice) {
// This list is guaranteed to have only one device in it.
let device = active.get_devices()[0]._delegate;
active._primaryDevice = device;
let devices = active.get_devices();
if (devices.length > 0) {
// This list is guaranteed to have at most one device in it.
let device = devices[0]._delegate;
active._primaryDevice = device;
}
}
}