create: Reinit netlist on each run

Will be easier to handle if we make the netlist react to connection
signals.
This commit is contained in:
Cole Robinson 2014-01-28 13:59:31 -05:00
parent bd15cd3d6e
commit 745ec7cb96
2 changed files with 16 additions and 5 deletions

View File

@ -189,6 +189,7 @@ class vmmGObjectUI(vmmGObject):
def __init__(self, filename, windowname, builder=None, topwin=None):
vmmGObject.__init__(self)
self._external_topwin = bool(topwin)
if filename:
uifile = os.path.join(self.config.get_ui_dir(), filename)
@ -222,7 +223,8 @@ class vmmGObjectUI(vmmGObject):
self.close()
vmmGObject.cleanup(self)
self.builder = None
self.topwin.destroy()
if not self._external_topwin:
self.topwin.destroy()
self.topwin = None
self._err = None

View File

@ -108,9 +108,7 @@ class vmmCreate(vmmGObjectUI):
self.config_window = None
self.config_window_signals = []
self.netlist = vmmNetworkList(self.conn, self.builder, self.topwin)
self.widget("config-netdev-ui-align").add(self.netlist.top_box)
self.netlist.connect("changed", self.netdev_changed)
self.netlist = None
self.builder.connect_signals({
"on_vmm_newcreate_delete_event" : self.close,
@ -197,6 +195,9 @@ class vmmCreate(vmmGObjectUI):
if self.storage_browser:
self.storage_browser.cleanup()
self.storage_browser = None
if self.netlist:
self.netlist.cleanup()
self.netlist = None
def remove_conn(self):
if not self.conn:
@ -213,7 +214,6 @@ class vmmCreate(vmmGObjectUI):
self.remove_conn()
self.conn = newconn
self.netlist.conn = self.conn
if self.conn:
self.set_conn_state()
@ -622,6 +622,15 @@ class vmmCreate(vmmGObjectUI):
self.widget("config-macaddr").set_text(newmac)
self.widget("config-advanced-expander").set_expanded(False)
if self.netlist:
self.widget("config-netdev-ui-align").remove(self.netlist.top_box)
self.netlist.cleanup()
self.netlist = None
self.netlist = vmmNetworkList(self.conn, self.builder, self.topwin)
self.widget("config-netdev-ui-align").add(self.netlist.top_box)
self.netlist.connect("changed", self.netdev_changed)
self.netlist.reset_state()
def populate_hv(self):