diff options
author | Benjamin Berg <bberg@redhat.com> | 2022-03-31 17:10:06 +0200 |
---|---|---|
committer | Benjamin Berg <bberg@redhat.com> | 2022-04-01 18:25:20 +0200 |
commit | 77a20b84e445ee9061909af078d38cdb1749fa28 (patch) | |
tree | bca4d0d05aa6f8097c3507a4660c0b17d989557c | |
parent | 51b4a39a810f01a20d34fc313d44af882674f761 (diff) | |
download | upower-77a20b84e445ee9061909af078d38cdb1749fa28.tar.gz |
device: Remove unplug, moving cycle breaking into dispose
Might as well use g_object_run_dispose to break the cycle to the display
device.
-rw-r--r-- | src/linux/up-device-idevice.c | 10 | ||||
-rw-r--r-- | src/linux/up-device-supply.c | 17 | ||||
-rw-r--r-- | src/up-daemon.c | 2 | ||||
-rw-r--r-- | src/up-device.c | 22 | ||||
-rw-r--r-- | src/up-device.h | 1 |
5 files changed, 32 insertions, 20 deletions
diff --git a/src/linux/up-device-idevice.c b/src/linux/up-device-idevice.c index 98182f7..acfc7c8 100644 --- a/src/linux/up-device-idevice.c +++ b/src/linux/up-device-idevice.c @@ -389,7 +389,6 @@ up_device_idevice_finalize (GObject *object) idevice->priv->start_id = 0; } - up_daemon_stop_poll (object); if (idevice->priv->client != NULL) lockdownd_client_free (idevice->priv->client); if (idevice->priv->dev != NULL) @@ -398,6 +397,14 @@ up_device_idevice_finalize (GObject *object) G_OBJECT_CLASS (up_device_idevice_parent_class)->finalize (object); } +static void +up_device_idevice_dispose (GObject *object) +{ + up_daemon_stop_poll (object); + + G_OBJECT_CLASS (up_device_idevice_parent_class)->dispose (object); +} + /** * up_device_idevice_class_init: **/ @@ -408,6 +415,7 @@ up_device_idevice_class_init (UpDeviceIdeviceClass *klass) UpDeviceClass *device_class = UP_DEVICE_CLASS (klass); object_class->finalize = up_device_idevice_finalize; + object_class->dispose = up_device_idevice_dispose; device_class->coldplug = up_device_idevice_coldplug; device_class->refresh = up_device_idevice_refresh; } diff --git a/src/linux/up-device-supply.c b/src/linux/up-device-supply.c index fc77773..5ae5467 100644 --- a/src/linux/up-device-supply.c +++ b/src/linux/up-device-supply.c @@ -1281,15 +1281,23 @@ up_device_supply_finalize (GObject *object) supply = UP_DEVICE_SUPPLY (object); g_return_if_fail (supply->priv != NULL); + g_free (supply->priv->energy_old); + g_free (supply->priv->energy_old_timespec); + + G_OBJECT_CLASS (up_device_supply_parent_class)->finalize (object); +} + +static void +up_device_supply_dispose (GObject *object) +{ + UpDeviceSupply *supply = UP_DEVICE_SUPPLY (object); + up_daemon_stop_poll (object); if (supply->priv->poll_timer_id > 0) g_source_remove (supply->priv->poll_timer_id); - g_free (supply->priv->energy_old); - g_free (supply->priv->energy_old_timespec); - - G_OBJECT_CLASS (up_device_supply_parent_class)->finalize (object); + G_OBJECT_CLASS (up_device_supply_parent_class)->dispose (object); } static void @@ -1336,6 +1344,7 @@ up_device_supply_class_init (UpDeviceSupplyClass *klass) UpDeviceClass *device_class = UP_DEVICE_CLASS (klass); object_class->finalize = up_device_supply_finalize; + object_class->dispose = up_device_supply_dispose; object_class->set_property = up_device_supply_set_property; object_class->get_property = up_device_supply_get_property; device_class->get_on_battery = up_device_supply_get_on_battery; diff --git a/src/up-daemon.c b/src/up-daemon.c index 738af99..a1ee2b2 100644 --- a/src/up-daemon.c +++ b/src/up-daemon.c @@ -517,7 +517,7 @@ up_daemon_shutdown (UpDaemon *daemon) up_device_list_clear (daemon->priv->power_devices, TRUE); /* release UpDaemon reference */ - up_device_unplug (daemon->priv->display_device); + g_object_run_dispose (G_OBJECT (daemon->priv->display_device)); } /** diff --git a/src/up-device.c b/src/up-device.c index 2c71b39..5051b38 100644 --- a/src/up-device.c +++ b/src/up-device.c @@ -449,19 +449,6 @@ bail: } /** - * up_device_unplug: - * - * Initiates destruction of %UpDevice, undoing the effects of - * up_device_coldplug. - */ -void -up_device_unplug (UpDevice *device) -{ - /* break circular dependency */ - g_clear_object (&device->priv->daemon); -} - -/** * up_device_get_statistics: **/ static gboolean @@ -716,6 +703,14 @@ up_device_finalize (GObject *object) G_OBJECT_CLASS (up_device_parent_class)->finalize (object); } +static void +up_device_dispose (GObject *object) +{ + g_clear_object (&UP_DEVICE (object)->priv->daemon); + + G_OBJECT_CLASS (up_device_parent_class)->dispose (object); +} + /** * up_device_class_init: **/ @@ -725,6 +720,7 @@ up_device_class_init (UpDeviceClass *klass) GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->notify = up_device_notify; object_class->finalize = up_device_finalize; + object_class->dispose = up_device_dispose; } /** diff --git a/src/up-device.h b/src/up-device.h index 58c0bd8..c3171d7 100644 --- a/src/up-device.h +++ b/src/up-device.h @@ -62,7 +62,6 @@ UpDevice *up_device_new (void); gboolean up_device_coldplug (UpDevice *device, UpDaemon *daemon, GObject *native); -void up_device_unplug (UpDevice *device); gboolean up_device_register_display_device (UpDevice *device, UpDaemon *daemon); UpDaemon *up_device_get_daemon (UpDevice *device); |