console: share one ActionBar instance

This fixes an issues where popping a view off the stack caused stale ActionBar
contents to be displayed.
This commit is contained in:
Aldo Cortesi 2016-07-21 15:41:43 +12:00
parent 6750ab899a
commit 33ffbc28ed
3 changed files with 4 additions and 4 deletions

View File

@ -462,6 +462,7 @@ class ConsoleMaster(flow.FlowMaster):
screen = self.ui,
handle_mouse = not self.options.no_mouse,
)
self.ab = statusbar.ActionBar()
if self.options.rfile:
ret = self.load_flows_path(self.options.rfile)

View File

@ -120,9 +120,8 @@ class StatusBar(urwid.WidgetWrap):
# type: (mitmproxy.console.master.ConsoleMaster, object) -> None
self.master = master
self.helptext = helptext
self.ab = ActionBar()
self.ib = urwid.WidgetWrap(urwid.Text(""))
super(StatusBar, self).__init__(urwid.Pile([self.ib, self.ab]))
super(StatusBar, self).__init__(urwid.Pile([self.ib, self.master.ab]))
signals.update_settings.connect(self.sig_update_settings)
signals.flowlist_change.connect(self.sig_update_settings)
master.options.changed.connect(self.sig_update_settings)
@ -132,7 +131,7 @@ class StatusBar(urwid.WidgetWrap):
self.redraw()
def keypress(self, *args, **kwargs):
return self.ab.keypress(*args, **kwargs)
return self.master.ab.keypress(*args, **kwargs)
def get_status(self):
r = []

View File

@ -6,7 +6,7 @@ from netlib import utils, tutils
def test_is_valid_host():
assert not utils.is_valid_host(b"")
assert utils.is_valid_host(b"one.two")
assert not utils.is_valid_host(b"one"*255)
assert not utils.is_valid_host(b"one" * 255)
assert utils.is_valid_host(b"one.two.")