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



commit 234c102a2078e6518af206e347f0488c0e52ad95
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 change this expectation. If there is an active connection,
    `_deviceAdded()` will eventually get to it, and then it will be in
    `_connectionItems`. Let's make `NMConnectionDevice._sync()` tolerate
    there being no active connection, in the knowledge that if there really
    *is* one, we'll end up entering the branch where it is set up, just
    later on.
    
    Closes: https://gitlab.gnome.org/GNOME/gnome-shell/issues/140

 js/ui/status/network.js | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/js/ui/status/network.js b/js/ui/status/network.js
index 3e3d0d1d2..7d460c2da 100644
--- a/js/ui/status/network.js
+++ b/js/ui/status/network.js
@@ -420,12 +420,14 @@ var NMConnectionDevice = new Lang.Class({
         this._deactivateItem.actor.visible = this._device.state > NM.DeviceState.DISCONNECTED;
 
         if (this._activeConnection == null) {
-            this._activeConnection = this._device.active_connection;
-
-            if (this._activeConnection) {
-                ensureActiveConnectionProps(this._activeConnection, this._client);
+            let activeConnection = this._device.active_connection;
+            if (activeConnection && activeConnection.connection) {
                 let item = this._connectionItems.get(this._activeConnection.connection.get_uuid());
-                item.setActiveConnection(this._activeConnection);
+                if (item) {
+                    this._activeConnection = activeConnection;
+                    ensureActiveConnectionProps(this._activeConnection, this._client);
+                    item.setActiveConnection(this._activeConnection);
+                }
             }
         }
 


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