[gnome-shell] network: don't assume NMActiveConnection has a device



commit 94ba52af0c52f789cb8cf81e1500765d0cbba98b
Author: Will Thompson <will willthompson co uk>
Date:   Fri Jun 21 10:47:40 2019 +0100

    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

 js/ui/status/network.js | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/js/ui/status/network.js b/js/ui/status/network.js
index 4ab82e9f2..7c2499d0e 100644
--- a/js/ui/status/network.js
+++ b/js/ui/status/network.js
@@ -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;
+        }
     }
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]