[Sugar-devel] [PATCH] Modem device icon: fix state detection (#4255)

Daniel Drake dsd at laptop.org
Tue Dec 11 05:08:19 EST 2012


Probably lacking an update from the NM-0.8 era, _update_state does
not correctly handle NM_DEVICE_STATE_IP_CHECK and
NM_DEVICE_STATE_SECONDARIES (triggered late in the connection-establishing
process after NM_DEVICE_STATE_IP_CONFIG).

This was causing backtraces like:
  File "/usr/share/sugar/extensions/deviceicon/network.py", line 856, in _update_state
    self._palette.update_state(gsm_state, reason)
  File "/usr/share/sugar/extensions/deviceicon/network.py", line 272, in update_state
    self._update_label_and_text(reason)
  File "/usr/share/sugar/extensions/deviceicon/network.py", line 310, in _update_label_and_text
    'text, %s' % str(self._current_state))
ValueError: Invalid GSM state while updating label and text, None

and it may have been confusing further code in the same class after.

Fix _update_state to more accurately identify the "connecting" states.
---
 extensions/deviceicon/network.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/extensions/deviceicon/network.py b/extensions/deviceicon/network.py
index ebbafdd..2a60481 100644
--- a/extensions/deviceicon/network.py
+++ b/extensions/deviceicon/network.py
@@ -846,7 +846,7 @@ class GsmDeviceView(TrayIcon):
             gsm_state = _GSM_STATE_NOT_READY
 
         elif (state >= network.NM_DEVICE_STATE_PREPARE) and \
-             (state <= network.NM_DEVICE_STATE_IP_CONFIG):
+             (state < network.NM_DEVICE_STATE_ACTIVATED):
             gsm_state = _GSM_STATE_CONNECTING
 
         elif state == network.NM_DEVICE_STATE_FAILED:
-- 
1.8.0.1



More information about the Sugar-devel mailing list