engine: connection-removed signal should only send URI

Since that's all that's really needed, and sending conn can interfere
with cleanup
This commit is contained in:
Cole Robinson 2011-04-12 11:50:10 -04:00
parent f8cbb6fc75
commit 8845447a98
4 changed files with 23 additions and 18 deletions

View File

@ -212,7 +212,7 @@ class vmmEngine(vmmGObject):
"connection-added": (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
[object]),
"connection-removed": (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
[object])
[str])
}
def __init__(self):
@ -519,8 +519,9 @@ class vmmEngine(vmmGObject):
def remove_connection(self, uri):
conn = self.connections[uri]["connection"]
conn.close()
self.emit("connection-removed", conn)
del self.connections[uri]
self.emit("connection-removed", uri)
self.config.remove_connection(conn.get_uri())
def connect(self, name, callback, *args):

View File

@ -855,17 +855,21 @@ class vmmManager(vmmGObjectUI):
newname = conn.get_pretty_desc_inactive(False, True)
self.conn_refresh_resources(conn, newname)
def _remove_connection(self, engine_ignore, conn):
def _remove_connection(self, engine_ignore, uri):
model = self.window.get_widget("vm-list").get_model()
parent = self.rows[conn.get_uri()].iter
if parent is not None:
parent = self.rows[uri].iter
if parent is None:
return
child = model.iter_children(parent)
while child is not None:
del self.rows[self.vm_row_key(model.get_value(child, ROW_HANDLE))]
model.remove(child)
child = model.iter_children(parent)
while child is not None:
del self.rows[self.vm_row_key(model.get_value(child, ROW_HANDLE))]
model.remove(child)
child = model.iter_children(parent)
model.remove(parent)
del self.rows[conn.get_uri()]
model.remove(parent)
del self.rows[uri]
#############################

View File

@ -353,10 +353,10 @@ class vmmMigrateDialog(vmmGObjectUI):
self.destconn_rows.append(newrow)
self.populate_dest_combo()
def dest_remove_connection(self, engine_ignore, conn):
def dest_remove_connection(self, engine_ignore, uri):
# Make sure connection isn't already present
for row in self.destconn_rows:
if row[1] and row[1].get_uri() == conn.get_uri():
if row[1] and row[1].get_uri() == uri:
self.destconn_rows.remove(row)
self.populate_dest_combo()

View File

@ -311,14 +311,14 @@ class vmmSystray(vmmGObject):
self.conn_state_changed(conn)
self.populate_vm_list(conn)
def conn_removed(self, engine_ignore, conn):
if not conn.get_uri() in self.conn_menuitems:
def conn_removed(self, engine_ignore, uri):
if not uri in self.conn_menuitems:
return
menu_item = self.conn_menuitems[conn.get_uri()]
menu_item = self.conn_menuitems[uri]
self.systray_menu.remove(menu_item)
del(self.conn_menuitems[conn.get_uri()])
self.conn_vm_menuitems[conn.get_uri()] = {}
del(self.conn_menuitems[uri])
self.conn_vm_menuitems[uri] = {}
self.repopulate_menu_list()