diff options
author | Kate Hsuan <hpa@redhat.com> | 2024-02-26 17:25:47 +0800 |
---|---|---|
committer | Kate Hsuan <hpa@redhat.com> | 2024-03-05 16:27:16 +0800 |
commit | bbb593d306c86fd7b61f67282e4006d73e40a181 (patch) | |
tree | c6ff66692d03b279f60fffa95fda338b38273493 | |
parent | 76e2b9e5719978cc2ffb92fcd422748776c17874 (diff) |
up-device: Remove history only on device id change
Remove the history when the device id was changed.
-rw-r--r-- | src/up-device.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/up-device.c b/src/up-device.c index e4b0b38..507c7a1 100644 --- a/src/up-device.c +++ b/src/up-device.c @@ -230,12 +230,16 @@ up_device_notify (GObject *object, GParamSpec *pspec) if (g_strcmp0 (pspec->name, "type") == 0 || g_strcmp0 (pspec->name, "is-present") == 0) { update_icon_name (device); - /* Clearing the history object will force lazily loading. */ - g_clear_object (&priv->history); + /* Clearing the history object for lazily loading when device id was changed. */ + if (priv->history != NULL && + !up_history_is_device_id_equal (priv->history, up_device_get_id(device))) + g_clear_object (&priv->history); } else if (g_strcmp0 (pspec->name, "vendor") == 0 || g_strcmp0 (pspec->name, "model") == 0 || g_strcmp0 (pspec->name, "serial") == 0) { - g_clear_object (&priv->history); + if (priv->history != NULL && + !up_history_is_device_id_equal (priv->history, up_device_get_id(device))) + g_clear_object (&priv->history); } else if (g_strcmp0 (pspec->name, "power-supply") == 0 || g_strcmp0 (pspec->name, "time-to-empty") == 0) { update_warning_level (device); |