details: Fix crash when deleting a device

This commit is contained in:
Cole Robinson 2013-04-16 19:17:47 -04:00
parent 84f8131d97
commit 2e66114cdf
2 changed files with 20 additions and 59 deletions

View File

@ -14,25 +14,9 @@ consider dropping python-distutils-extra dep. I think we rely on about 300
we can prob reimplement the bits that are important to us fairly easilly.
python3? consider it
removing hardware can give:
Traceback (most recent call last):
File "/home/crobinso/src/virt-manager/src/virtManager/details.py", line 1254, in hw_changed
if self.compare_hw_rows(newrow, oldrow):
File "/home/crobinso/src/virt-manager/src/virtManager/details.py", line 1226, in compare_hw_rows
if row1[idx] != row2[idx]:
File "/usr/lib64/python2.7/site-packages/gi/overrides/Gtk.py", line 1136, in __getitem__
return self.model.get_value(self.iter, key)
File "/usr/lib64/python2.7/site-packages/gi/types.py", line 48, in function
return info.invoke(*args, **kwargs)
TypeError: unknown type (null)
start a spice guest, shrink the window to smaller than guest resolution, scrollbars work but don't have any actual 'bar'.
Manager spacing bug
===================
@ -47,7 +31,6 @@ spacing is weird in manager, prefs window. cant have unequal tree rows
- list size issues: master actually has bigger list size than collapsed gtk3 rows, maybe that is part of the issue.
Object leaks
============
@ -55,19 +38,3 @@ objects leak on cleanup, pygobject has reference counting issues
- https://bugzilla.gnome.org/show_bug.cgi?id=692044
- https://bugzilla.gnome.org/show_bug.cgi?id=693111
- leak detection disabled in the manager.py for now
Problems in other packages
==========================
gconf set_list: https://bugzilla.gnome.org/show_bug.cgi?id=681433
gtk tooltip: https://bugzilla.gnome.org/show_bug.cgi?id=691639
Keyring bindings broken: https://bugzilla.gnome.org/show_bug.cgi?id=691638
pygobject ctrl-c issue: https://bugzilla.gnome.org/show_bug.cgi?id=691658
get option list for --help: https://bugzilla.gnome.org/show_bug.cgi?id=691659
pygobject row[idx] = None: https://bugzilla.gnome.org/show_bug.cgi?id=691660
rcm-tools koji virt-install patch: http://post-office.corp.redhat.com/archives/rcm-tools/2012-February/msg00054.html

View File

@ -368,7 +368,7 @@ class vmmDetails(vmmGObjectUI):
w, h = self.vm.get_details_window_size()
self.topwin.set_default_size(w or 800, h or 600)
self.oldhwrow = None
self.oldhwkey = None
self.addhwmenu = None
self.keycombo_menu = None
self.init_menus()
@ -535,7 +535,7 @@ class vmmDetails(vmmGObjectUI):
self.refresh_vm_state()
def _cleanup(self):
self.oldhwrow = None
self.oldhwkey = None
if self.addhw:
self.addhw.cleanup()
@ -1237,17 +1237,6 @@ class vmmDetails(vmmGObjectUI):
return page
def compare_hw_rows(self, row1, row2):
if row1 == row2:
return True
if not row1 or not row2:
return False
for idx in range(row1.model.get_n_columns()):
if row1[idx] != row2[idx]:
return False
return True
def has_unapplied_changes(self, row):
if not row:
return False
@ -1269,22 +1258,27 @@ class vmmDetails(vmmGObjectUI):
def hw_changed(self, ignore):
newrow = self.get_hw_row()
oldrow = self.oldhwrow
model = self.widget("hw-list").get_model()
if self.compare_hw_rows(newrow, oldrow):
if newrow[HW_LIST_COL_DEVICE] == self.oldhwkey:
return
if self.has_unapplied_changes(oldrow):
oldhwrow = None
for row in model:
if row[HW_LIST_COL_DEVICE] == self.oldhwkey:
oldhwrow = row
break
if self.has_unapplied_changes(oldhwrow):
# Unapplied changes, and syncing them failed
pageidx = 0
for idx in range(len(model)):
if self.compare_hw_rows(model[idx], oldrow):
if model[idx][HW_LIST_COL_DEVICE] == self.oldhwkey:
pageidx = idx
break
self.set_hw_selection(pageidx, disable_apply=False)
else:
self.oldhwrow = newrow
self.oldhwkey = newrow[HW_LIST_COL_DEVICE]
self.hw_selected()
def hw_selected(self, page=None):
@ -3421,18 +3415,18 @@ class vmmDetails(vmmGObjectUI):
hw_list_model = self.widget("hw-list").get_model()
hw_list_model.clear()
def add_hw_list_option(title, page_id, data, icon_name):
def add_hw_list_option(title, page_id, icon_name):
hw_list_model.append([title, icon_name,
Gtk.IconSize.LARGE_TOOLBAR,
page_id, data])
page_id, title])
add_hw_list_option("Overview", HW_LIST_TYPE_GENERAL, [], "computer")
add_hw_list_option("Overview", HW_LIST_TYPE_GENERAL, "computer")
if not self.is_customize_dialog:
add_hw_list_option("Performance", HW_LIST_TYPE_STATS, [],
add_hw_list_option("Performance", HW_LIST_TYPE_STATS,
"utilities-system-monitor")
add_hw_list_option("Processor", HW_LIST_TYPE_CPU, [], "device_cpu")
add_hw_list_option("Memory", HW_LIST_TYPE_MEMORY, [], "device_mem")
add_hw_list_option("Boot Options", HW_LIST_TYPE_BOOT, [], "system-run")
add_hw_list_option("Processor", HW_LIST_TYPE_CPU, "device_cpu")
add_hw_list_option("Memory", HW_LIST_TYPE_MEMORY, "device_mem")
add_hw_list_option("Boot Options", HW_LIST_TYPE_BOOT, "system-run")
self.repopulate_hw_list()
@ -3443,7 +3437,7 @@ class vmmDetails(vmmGObjectUI):
currentDevices = []
def dev_cmp(origdev, newdev):
if not origdev:
if isinstance(origdev, str):
return False
if origdev == newdev: