Subject: host: unselect_all members before clear model From: Chen Hanxiao chenhanxiao@cn.fujitsu.com Fri Mar 14 09:04:34 2014 +0800 Date: Fri Mar 14 09:04:52 2014 +0800: Git: 1d3980015a942e5aceee0233c9b90d2bbe32ffdd Interface_selected is being triggered by model.clear() in populate_interfaces. It usually calls interface_selected on every interface after the current selected row. So the gtk code is probably removing the first row over and over, and when it removes the current selection (the interface we are deleting), it selects the next row in line. It will raise a KeyError. This patch will fix this issue. Signed-off-by: Chen Hanxiao diff --git a/virtManager/host.py b/virtManager/host.py index c8d7ee0..a1aa2fd 100644 --- a/virtManager/host.py +++ b/virtManager/host.py @@ -679,6 +679,7 @@ class vmmHost(vmmGObjectUI): curnet = self.current_network() net_list = self.widget("net-list") + net_list.get_selection().unselect_all() model.clear() for uuid in self.conn.list_net_uuids(): net = self.conn.get_net(uuid) @@ -1220,6 +1221,7 @@ class vmmHost(vmmGObjectUI): curiface = self.current_interface() iface_list = self.widget("interface-list") + iface_list.get_selection().unselect_all() model.clear() for name in self.conn.list_interface_names(): iface = self.conn.get_interface(name) @@ -1234,6 +1236,7 @@ class vmmHost(vmmGObjectUI): interface = self.current_interface() child_list = self.widget("interface-child-list") model = child_list.get_model() + child_list.get_selection().unselect_all() model.clear() if not interface: @@ -1278,6 +1281,7 @@ def populate_storage_pools(pool_list, conn, curpool): model = pool_list.get_model() # Prevent events while the model is modified pool_list.set_model(None) + pool_list.get_selection().unselect_all() model.clear() for uuid in conn.list_pool_uuids(): per = get_pool_size_percent(conn, uuid) @@ -1297,6 +1301,7 @@ def populate_storage_pools(pool_list, conn, curpool): def populate_storage_volumes(list_widget, pool, sensitive_cb): vols = pool and pool.get_volumes() or {} model = list_widget.get_model() + list_widget.get_selection().unselect_all() model.clear() for key in vols.keys():