Fix UI sync bugs introduced by flow serialization.

This commit is contained in:
Aldo Cortesi 2011-01-26 22:17:42 +13:00
parent 635f7a971d
commit bd6c0499fb
3 changed files with 10 additions and 3 deletions

View File

@ -109,6 +109,8 @@ class ConnectionItem(WWrap):
class ConnectionListView(urwid.ListWalker): class ConnectionListView(urwid.ListWalker):
def __init__(self, master, state): def __init__(self, master, state):
self.master, self.state = master, state self.master, self.state = master, state
if self.state.flow_list:
self.set_focus(0)
def get_focus(self): def get_focus(self):
f, i = self.state.get_focus() f, i = self.state.get_focus()
@ -572,6 +574,7 @@ class ConsoleMaster(controller.Master):
('key', "q"), ":back ", ('key', "q"), ":back ",
] ]
def __init__(self, server, options): def __init__(self, server, options):
self.conn_list_view = None
self.set_palette() self.set_palette()
controller.Master.__init__(self, server) controller.Master.__init__(self, server)
self.state = ConsoleState() self.state = ConsoleState()
@ -689,8 +692,9 @@ class ConsoleMaster(controller.Master):
self.statusbar.message(str(v)) self.statusbar.message(str(v))
return return
self.state.load_flows(data, ConsoleFlow) self.state.load_flows(data, ConsoleFlow)
self.conn_list_view.set_focus(0) if self.conn_list_view:
self.sync_list_view() self.conn_list_view.set_focus(0)
self.sync_list_view()
def helptext(self): def helptext(self):
text = [] text = []

View File

@ -212,7 +212,8 @@ class State:
Replaces the matching connection object with a ReplayConnection object. Replaces the matching connection object with a ReplayConnection object.
""" """
conn = self.get_connection(f) conn = self.get_connection(f)
del self.flow_map[conn] if conn in self.flow_map:
del self.flow_map[conn]
f.revert() f.revert()
self.flow_map[f.connection] = f self.flow_map[f.connection] = f

View File

@ -78,4 +78,6 @@ if __name__ == '__main__':
) )
server = proxy.ProxyServer(options.port) server = proxy.ProxyServer(options.port)
m = console.ConsoleMaster(server, options) m = console.ConsoleMaster(server, options)
for i in args:
m.load_flows(i)
m.run() m.run()