wicd-curses: Crash and raise IndexError, "No widget at position %s"

Bug #1132053 reported by François Boulogne
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
wicd
Fix Committed
High
Unassigned

Bug Description

Hi,

I'm running wicd on archlinux.
There is my version:
wicd-curses --version -I-
wicd-curses-uimod (using wicd 1.7.2.4)

The traceback:
ERROR:dbus.connection:Exception in handler for D-Bus signal:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/dbus/connection.py", line 230, in maybe_handle_message
    self._handler(*args, **kwargs)
  File "/usr/share/wicd/curses/wicd-curses.py", line 788, in dbus_scan_finished
    self.unlock_screen()
  File "/usr/share/wicd/curses/wicd-curses.py", line 621, in unlock_screen
    self.update_netlist(force_check=True)
  File "/usr/share/wicd/curses/wicd-curses.py", line 88, in wrapper
    return func(*args, **kargs)
  File "/usr/share/wicd/curses/wicd-curses.py", line 703, in update_netlist
    self.wlessLB.set_focus(self.focusloc[1])
  File "/usr/lib/python2.7/site-packages/urwid/listbox.py", line 567, in set_focus
    self.body.set_focus(position)
  File "/usr/lib/python2.7/site-packages/urwid/listbox.py", line 178, in set_focus
    raise IndexError, "No widget at position %s" % (position,)
IndexError: No widget at position 2

I don't exactly known when it crashes. It seems it happens when a new connexion is set up.
Not reproducible each time, it occurs about Three times a week (my computer is running half a day).

Revision history for this message
radaiming (radaiming) wrote :

I also met this problem, the version is:
 $ wicd-curses --version -I-
wicd-curses-uimod (using wicd 1.7.2.4)

It's easy to reproduce in a environment with many access points, continue refresh and move the focus to the access point at the bottom each time, when the numbers of access points scanned this time is less than last time, it can't focus on a non-exist access point, crash comes out.

I've view some code and get a solution, change

    self.wlessLB.set_focus(self.focusloc[1])
into
    self.wlessLB.set_focus(min(self.focusloc[1], len(self.wlessLB.body) -1))

in line 703 of wicd-curses.py, it will focus on last access point when get less access points then last scan.

Revision history for this message
radaiming (radaiming) wrote :

I found my fix is bad, will cause other problems, I wrote another dirty fix for myself, but hope to get better fixes:

  File "/usr/share/wicd/curses/wicd-curses.py", line 703, in update_netlist
    self.wlessLB.set_focus(min(self.focusloc[1], len(self.wlessLB.body) -1))
TypeError: object of type 'PollingListWalker' has no len()

Revision history for this message
FlashYoshi (tivervac) wrote :

You can indeed reproduce this as @radaiming said.
This fix I wrote seems to work:

if self.focusloc[1] < len(wlessL):
    self.wlessLB.set_focus(self.focusloc[1])
else:
    self.wlessLB.set_focus(len(wlessL) - 1)

or as @radaiming would do it

self.wlessLB.set_focus(min(self.focusloc[1], len(wlessL) - 1))

Revision history for this message
FlashYoshi (tivervac) wrote :

Patch (based on main branch) for my above comment.
Edited file: http://bazaar.launchpad.net/~wicd-devel/wicd/experimental/view/head:/curses/wicd-curses.py

Changed in wicd:
status: New → Confirmed
Revision history for this message
Pieter Leclerc (pieterleclerc-deactivatedaccount) wrote :

Improved and applied your patch. Thanks for making wicd more stable!

=== modified file 'curses/wicd-curses.py'
--- curses/wicd-curses.py 2014-12-19 14:40:39 +0000
+++ curses/wicd-curses.py 2014-12-20 09:30:43 +0000
@@ -872,7 +872,8 @@
                         get_body().set_focus(self.focusloc[1])
                 else:
                     if self.wlessLB != self.no_wlan:
- self.thePile.get_focus().set_focus(self.focusloc[1])
+ # Set the focus to the last selected item, but never past the length of the list
+ self.thePile.get_focus().set_focus(min(self.focusloc[1], len(wlessL) - 1))
                     else:
                         self.thePile.set_focus(self.wiredCB)
             else:
@@ -885,7 +886,8 @@
                 if self.focusloc[1] is None:
                     self.focusloc[1] = 0
                 if self.wlessLB != self.no_wlan:
- self.wlessLB.set_focus(self.focusloc[1])
+ # Set the focus to the last selected item, but never past the length of the list
+ self.wlessLB.set_focus(min(self.focusloc[1], len(wlessL) - 1))

         self.prev_state = state
         if not firstrun:

Changed in wicd:
importance: Undecided → High
assignee: nobody → Tom Van Braeckel (tomvanbraeckel)
milestone: none → 1.7.3
status: Confirmed → Fix Committed
Revision history for this message
qbit (porcedda) wrote :

Hi all,

i use wicd-curses and I notice the exact bug claimed here. I saw above the patch by tivervac and its improvement by tomvanbraeckel, and I have two questions: do I have to only apply the last patch, or both two (first the tivervac one, then tomvanbraeckel one)? And does it work with wicd 1.7.3-1?

Thanks very much, and sorry for the behave!
Regards

Revision history for this message
Pieter Leclerc (pieterleclerc-deactivatedaccount) wrote :

Only the improved patch (the last one) will do. Try it on wicd 1.7.3-1!

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.