New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Device change event: properties are not updated #9

Closed
shatsky opened this Issue Aug 8, 2014 · 2 comments

Comments

Projects
None yet
2 participants
@shatsky

shatsky commented Aug 8, 2014

While console debug messages show actual property changes on device change event, properties do not get updated in the GUI.
This happens because DeviceFinder.device_changed() doesn't update device in self.devices_tree dict. However, if we fix it, old_device = self.device_finder.get_devices_tree()[device.path] in UdevDiscoverGUI.changed_device() will not get an old device instance for logging. I think we have to pass it via the signal.

@shatsky

This comment has been minimized.

Show comment
Hide comment
@shatsky

shatsky Aug 9, 2014

Seems to work.
In udev-discover.in:

@@ -334,18 +337,26 @@ class UDevDiscoverGUI(GConfStore):
         self.logger.info(_('Device removed: %s') % device.nice_label)

-    def changed_device(self, device_finder, device):
-        old_device = self.device_finder.get_devices_tree()[device.path]
+    def changed_device(self, device_finder, device, old_device):

         if self.rows.has_key(device.path):
             # Remove from tree first

In udevdiscover/devicefinder.py:

@@ -49,7 +49,7 @@ class DeviceFinder(GObject.GObject):
         'removed': (GObject.SignalFlags.RUN_LAST, None, 
             (GObject.TYPE_PYOBJECT,)),
         'changed': (GObject.SignalFlags.RUN_LAST, None, 
-            (GObject.TYPE_PYOBJECT,)),
+            (GObject.TYPE_PYOBJECT, GObject.TYPE_PYOBJECT,)),
     }

     def __init__(self, subsystems='', parent_tree=False):
@@ -143,7 +143,9 @@ class DeviceFinder(GObject.GObject):
         '''Called when a device has been updated'''

         dev = device.get_device_object(gudevice)
-        self.emit('changed', dev)
+        old_dev = self.devices_tree[dev.path]
+        self.devices_tree[dev.path] = dev
+        self.emit('changed', dev, old_dev)

 GObject.type_register(DeviceFinder)

shatsky commented Aug 9, 2014

Seems to work.
In udev-discover.in:

@@ -334,18 +337,26 @@ class UDevDiscoverGUI(GConfStore):
         self.logger.info(_('Device removed: %s') % device.nice_label)

-    def changed_device(self, device_finder, device):
-        old_device = self.device_finder.get_devices_tree()[device.path]
+    def changed_device(self, device_finder, device, old_device):

         if self.rows.has_key(device.path):
             # Remove from tree first

In udevdiscover/devicefinder.py:

@@ -49,7 +49,7 @@ class DeviceFinder(GObject.GObject):
         'removed': (GObject.SignalFlags.RUN_LAST, None, 
             (GObject.TYPE_PYOBJECT,)),
         'changed': (GObject.SignalFlags.RUN_LAST, None, 
-            (GObject.TYPE_PYOBJECT,)),
+            (GObject.TYPE_PYOBJECT, GObject.TYPE_PYOBJECT,)),
     }

     def __init__(self, subsystems='', parent_tree=False):
@@ -143,7 +143,9 @@ class DeviceFinder(GObject.GObject):
         '''Called when a device has been updated'''

         dev = device.get_device_object(gudevice)
-        self.emit('changed', dev)
+        old_dev = self.devices_tree[dev.path]
+        self.devices_tree[dev.path] = dev
+        self.emit('changed', dev, old_dev)

 GObject.type_register(DeviceFinder)

@fontanon fontanon closed this in 44d2605 Aug 9, 2014

@fontanon

This comment has been minimized.

Show comment
Hide comment
@fontanon

fontanon Aug 9, 2014

Owner

Change integrated in udev-discover-0.2.3
Thanks

Owner

fontanon commented Aug 9, 2014

Change integrated in udev-discover-0.2.3
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment