You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
changed_device() updates device in tree by simply removing it and then adding again; treestore.remove() removes it with child devices, and subsequently called add_new_device() doesn't add them back.
My quick&dirty solution is to use treestore.set() instead of removing and re-adding:
@@ -340,12 +343,20 @@ class UDevDiscoverGUI(GConfStore):
if self.rows.has_key(device.path):
# Remove from tree first
ref_row = self.rows[device.path]
treeiter = self.devices_treestore.get_iter(ref_row.get_path())
- self.devices_treestore.remove(treeiter)
- del(self.rows[device.path])
+ # treestore.remove(treeiter) removes node with all children; we need to update without removing or move children to a new node first
+ self.devices_treestore.set(treeiter, range(6), [device.path,
+ device_icon, device.nice_label, device.subsystem, False,
+ device.name])
# Add again
- row_ref = self.add_new_device(device)
+ row_ref = self.rows[device.path]
if self.options['expanded']:
iter_path = row_ref.get_path()
I consider making add_new_device handle both adding and updating: it will check whether device.path is in self.rows, then update existing device row if it is or add a now one it if not.
The text was updated successfully, but these errors were encountered:
shatsky
changed the title
Child devices are dropped if device is changed
Device change event: child devices are dropped
Aug 8, 2014
changed_device()
updates device in tree by simply removing it and then adding again;treestore.remove()
removes it with child devices, and subsequently calledadd_new_device()
doesn't add them back.My quick&dirty solution is to use
treestore.set()
instead of removing and re-adding:I consider making
add_new_device
handle both adding and updating: it will check whether device.path is inself.rows
, then update existing device row if it is or add a now one it if not.The text was updated successfully, but these errors were encountered: