From 33ffbc28ede02d9238473e0569a85ce0ede061e6 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Thu, 21 Jul 2016 15:41:43 +1200 Subject: [PATCH] console: share one ActionBar instance This fixes an issues where popping a view off the stack caused stale ActionBar contents to be displayed. --- mitmproxy/console/master.py | 1 + mitmproxy/console/statusbar.py | 5 ++--- test/netlib/test_utils.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mitmproxy/console/master.py b/mitmproxy/console/master.py index 59d074563..9b68f732f 100644 --- a/mitmproxy/console/master.py +++ b/mitmproxy/console/master.py @@ -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) diff --git a/mitmproxy/console/statusbar.py b/mitmproxy/console/statusbar.py index f0da9dcd9..ee9adcfaa 100644 --- a/mitmproxy/console/statusbar.py +++ b/mitmproxy/console/statusbar.py @@ -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 = [] diff --git a/test/netlib/test_utils.py b/test/netlib/test_utils.py index f6acec03b..9dcbffd81 100644 --- a/test/netlib/test_utils.py +++ b/test/netlib/test_utils.py @@ -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.")