[gnome-shell/wip/network-active-connection-check-first] network: When processing new devices, look at the active connection first



commit 9a8f2835fe8e6fd4bf4cc560189672f248b3bf8a
Author: Iain Lane <iainl gnome org>
Date:   Thu Aug 16 11:59:36 2018 +0100

    network: When processing new devices, look at the active connection first
    
    `NMConnectionDevice._sync()` is responsible for setting up the active
    connection that we'll end up displaying. It expects the active
    connection to already be in a Map `_connectionItems`. If it isn't in
    there, we get a null dereference and the indicator can get into a weird
    state where it doesn't display devices / connections properly.
    
    Connections are added in the first place when processing new devices in
    NMApplet._deviceAdded(). We iterate over the list of connections and
    call `checkConnection()` on each of them, which ends up calling
    `NMConnectionDevice._sync()` and failing as described above if the
    active connection hasn't yet been processed.
    
    Let's ensure that the active connection, if there is one, is always
    processed first.
    
    Closes: https://gitlab.gnome.org/GNOME/gnome-shell/issues/140

 js/ui/status/network.js | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
---
diff --git a/js/ui/status/network.js b/js/ui/status/network.js
index 3e3d0d1d2..378c33b26 100644
--- a/js/ui/status/network.js
+++ b/js/ui/status/network.js
@@ -1771,8 +1771,18 @@ var NMApplet = new Lang.Class({
                 this._syncDeviceNames();
 
             if (wrapper instanceof NMConnectionSection) {
+                // If we have an active connection, make sure it's added first.
+                // NMConnectionDevice._sync() assumes that if we have one it
+                // has already been added by the time it gets called (which
+                // happens as a result of calling checkConnection() below.
+                let activeConnection = device.active_connection;
+                if (activeConnection && activeConnection.connection)
+                    wrapper.checkConnection(activeConnection.connection);
+
                 this._connections.forEach(connection => {
-                    wrapper.checkConnection(connection);
+                    if (activeConnection == null ||
+                        connection != activeConnection.connection)
+                        wrapper.checkConnection(connection);
                 });
             }
         }


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