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

[tor-commits] [nyx/master] Menus caused stacktrace when you pressed 'm'



commit 4de4e4ca8a719196b971e9e13ebc0f61b67123bb
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sat Jun 27 16:04:59 2015 -0700

    Menus caused stacktrace when you pressed 'm'
    
    Issue spotted by Steven. Revisions to popup handling broke the menu...
    
      Traceback (most recent call last):
        File "./run_nyx", line 8, in <module>
          nyx.main()
        File "/home/atagar/Desktop/nyx/nyx/__init__.py", line 30, in main
          nyx.starter.main()
        File "/home/atagar/Desktop/nyx/stem/util/conf.py", line 288, in wrapped
          return func(*args, config = config, **kwargs)
        File "/home/atagar/Desktop/nyx/nyx/starter.py", line 91, in main
          curses.wrapper(nyx.controller.start_nyx)
        File "/usr/lib/python2.7/curses/wrapper.py", line 43, in wrapper
          return func(stdscr, *args, **kwds)
        File "/home/atagar/Desktop/nyx/nyx/controller.py", line 594, in start_nyx
          nyx.menu.menu.show_menu()
        File "/home/atagar/Desktop/nyx/nyx/menu/menu.py", line 119, in show_menu
          _draw_submenu(cursor, 1, 1, selection_left)
        File "/home/atagar/Desktop/nyx/nyx/menu/menu.py", line 159, in _draw_submenu
          popup, _, _ = nyx.popups.init(len(submenu.get_children()), menu_width, top, left, below_static = False)
      AttributeError: 'module' object has no attribute 'init'
---
 nyx/menu/menu.py |   10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/nyx/menu/menu.py b/nyx/menu/menu.py
index 34e9a67..ef36063 100644
--- a/nyx/menu/menu.py
+++ b/nyx/menu/menu.py
@@ -156,12 +156,10 @@ def _draw_submenu(cursor, level, top, left):
   label_format = ' %%-%is%%-%is%%-%is ' % (prefix_col_size, middle_col_size, suffix_col_size)
   menu_width = len(label_format % ('', '', ''))
 
-  popup, _, _ = nyx.popups.init(len(submenu.get_children()), menu_width, top, left, below_static = False)
+  with nyx.popups.popup_window(len(submenu.get_children()), menu_width, top, left, below_static = False) as (popup, _, _):
+    if not popup:
+      return
 
-  if not popup:
-    return
-
-  try:
     # sets the background color
 
     popup.win.bkgd(' ', curses.A_STANDOUT | ui_tools.get_color('red'))
@@ -183,5 +181,3 @@ def _draw_submenu(cursor, level, top, left):
     # shows the next submenu
 
     _draw_submenu(cursor, level + 1, top + selection_top, left + menu_width)
-  finally:
-    nyx.popups.finalize()

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits