diff options
author | Benjamin Berg <bberg@redhat.com> | 2022-05-12 10:06:46 +0200 |
---|---|---|
committer | Benjamin Berg <bberg@redhat.com> | 2022-05-12 10:13:15 +0200 |
commit | 71f19086839469f0d3ea05fe7a1a392eb9bdef03 (patch) | |
tree | e56d86a22bdfcd26b630141a2a08af34336dd911 /src/up-device-list.c | |
parent | 565b3531d67af0d71b4ecd3838cb46dfccaab3a1 (diff) | |
download | upower-71f19086839469f0d3ea05fe7a1a392eb9bdef03.tar.gz |
daemon: Fix reference counting at daemon shutdown
Commit b78a2ab980ca ("daemon: Stop passing UpDevice reference to the
daemon") fixed the fact that the signal passed a reference to the
daemon. This fix also implied that the UpDaemon object does not own a
reference to the device itself, instead relying on the UpDeviceList to
keep it alive.
With this change, there is no need to drop the extra reference when
clearing the device list, remove the code accordingly.
Reported-by: Alberts Muktupāvels <alberts.muktupavels@gmail.com>
Diffstat (limited to 'src/up-device-list.c')
-rw-r--r-- | src/up-device-list.c | 20 |
1 files changed, 2 insertions, 18 deletions
diff --git a/src/up-device-list.c b/src/up-device-list.c index d7250f5..35a9999 100644 --- a/src/up-device-list.c +++ b/src/up-device-list.c @@ -132,33 +132,17 @@ up_device_list_remove (UpDeviceList *list, gpointer device) } /** - * up_device_list_remove_cb: - **/ -static gboolean -up_device_list_remove_all_cb (gpointer key, gpointer value, gpointer user_data) -{ - return TRUE; -} - -/** * up_device_list_clear: * @list: This class instance - * @unref_it: %TRUE if you own a reference to the objects and want to drop it. * * Clear the contents of this list. **/ void -up_device_list_clear (UpDeviceList *list, gboolean unref_it) +up_device_list_clear (UpDeviceList *list) { g_return_if_fail (UP_IS_DEVICE_LIST (list)); - /* caller owns these objects, but wants to destroy them */ - if (unref_it) - g_ptr_array_foreach (list->priv->array, (GFunc) g_object_unref, NULL); - - /* remove all devices from the db */ - g_hash_table_foreach_remove (list->priv->map_native_path_to_device, - up_device_list_remove_all_cb, NULL); + g_hash_table_remove_all (list->priv->map_native_path_to_device); g_ptr_array_set_size (list->priv->array, 0); } |