From 20f1457d158bfae36642199e14beeefdb8fe2759 Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Sat, 26 Mar 2011 18:38:20 +0100 Subject: [PATCH] NetworkStatus: ignore invalid and unsupported connection types Some connection types (like wimax) are not supported by the menu, and should be ignored instead of throwing exceptions. Also, NetworkManager had a bug that sent connections with invalid settings. This should not happen, but in case it does, we will not blow up, but just log a warning and continue silently. https://bugzilla.gnome.org/show_bug.cgi?id=646355 --- js/ui/status/network.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/js/ui/status/network.js b/js/ui/status/network.js index 1bb73e7d3..300c08dd2 100644 --- a/js/ui/status/network.js +++ b/js/ui/status/network.js @@ -22,6 +22,7 @@ const Gettext = imports.gettext.domain('gnome-shell'); const _ = Gettext.gettext; const NMConnectionCategory = { + INVALID: 'invalid', WIRED: 'wired', WIRELESS: 'wireless', WWAN: 'wwan', @@ -1928,11 +1929,12 @@ NMApplet.prototype = { this._connections.splice(connection); let section = connection._section; + if (section == NMConnectionCategory.VPN) { this._devices.vpn.device.removeConnection(connection); if (this._devices.vpn.device.empty) this._devices.vpn.section.actor.hide(); - } else { + } else if (section != NMConnectionCategory.INVALID) { let devices = this._devices[section].devices; for (let i = 0; i < devices.length; i++) devices[i].removeConnection(connection); @@ -1946,16 +1948,19 @@ NMApplet.prototype = { _updateConnection: function(connection) { let connectionSettings = connection.get_setting_by_name(NetworkManager.SETTING_CONNECTION_SETTING_NAME); connection._type = connectionSettings.type; - connection._section = this._ctypes[connection._type]; + + connection._section = this._ctypes[connection._type] || NMConnectionCategory.INVALID; connection._name = connectionSettings.id; connection._uuid = connectionSettings.uuid; connection._timestamp = connectionSettings.timestamp; let section = connection._section; + + if (connection._section == NMConnectionCategory.INVALID) + return; if (section == NMConnectionCategory.VPN) { this._devices.vpn.device.checkConnection(connection); this._devices.vpn.section.actor.show(); - connection._everAdded = true; } else { let devices = this._devices[section].devices; for (let i = 0; i < devices.length; i++) {