inspection: Check can_set_row_none before setting icon to None.

Previously one could set the icon field of a tree model to None, but
with Gtk3 and older versions of pygobject3 this would fail.

Use can_set_row_none to test for this condition and work around it.

The previous traceback was:

Traceback (most recent call last):
  File "/home/rjones/d/virt-manager/virtManager/manager.py", line 981, in vm_inspection_changed
    self.get_inspection_icon_pixbuf(vm, 16, 16)
  File "/usr/lib64/python2.7/site-packages/gi/overrides/Gtk.py", line 1152, in __setitem__
    self.model.set_value(self.iter, key, value)
  File "/usr/lib64/python2.7/site-packages/gi/overrides/Gtk.py", line 1298, in set_value
    Gtk.TreeStore.set_value(self, treeiter, column, value)
  File "/usr/lib64/python2.7/site-packages/gi/types.py", line 47, in function
    return info.invoke(*args, **kwargs)
TypeError: Argument 3 does not allow None as a value
This commit is contained in:
Richard W.M. Jones 2013-06-28 18:45:53 +01:00 committed by Cole Robinson
parent ab312910f2
commit 9d5c1cdb1c

View File

@ -977,8 +977,10 @@ class vmmManager(vmmGObjectUI):
return
row = self.rows[self.vm_row_key(vm)]
row[ROW_INSPECTION_OS_ICON] = \
self.get_inspection_icon_pixbuf(vm, 16, 16)
new_icon = self.get_inspection_icon_pixbuf(vm, 16, 16)
if not can_set_row_none:
new_icon = new_icon or ""
row[ROW_INSPECTION_OS_ICON] = new_icon
model.row_changed(row.path, row.iter)
def get_inspection_icon_pixbuf(self, vm, w, h):