diff options
author | Michal Ratajsky <[email protected]> | 2014-10-23 22:02:39 +0200 |
---|---|---|
committer | Michal Ratajsky <[email protected]> | 2014-10-23 22:02:39 +0200 |
commit | 09c9b73913574a6862135bbcb9d7c2da1f3eea23 (patch) | |
tree | fe92da0a6e69d4b5341063a752ccbc01e40ceab1 /backends/pulse/pulse-device-switch.c | |
parent | b9e004261b979b885e7348484e302176b30d5b54 (diff) | |
download | libmatemixer-09c9b73913574a6862135bbcb9d7c2da1f3eea23.tar.bz2 libmatemixer-09c9b73913574a6862135bbcb9d7c2da1f3eea23.tar.xz |
Fix memory management problems
Diffstat (limited to 'backends/pulse/pulse-device-switch.c')
-rw-r--r-- | backends/pulse/pulse-device-switch.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/backends/pulse/pulse-device-switch.c b/backends/pulse/pulse-device-switch.c index 7a43d0a..bc2490d 100644 --- a/backends/pulse/pulse-device-switch.c +++ b/backends/pulse/pulse-device-switch.c @@ -129,7 +129,11 @@ pulse_device_switch_set_property (GObject *object, switch (param_id) { case PROP_DEVICE: /* Construct-only object */ - swtch->priv->device = g_value_dup_object (value); + swtch->priv->device = g_value_get_object (value); + + if (swtch->priv->device != NULL) + g_object_add_weak_pointer (G_OBJECT (swtch->priv->device), + (gpointer *) &swtch->priv->device); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); @@ -152,8 +156,10 @@ pulse_device_switch_dispose (GObject *object) swtch = PULSE_DEVICE_SWITCH (object); - g_clear_object (&swtch->priv->device); - + if (swtch->priv->profiles != NULL) { + g_list_free_full (swtch->priv->profiles, g_object_unref); + swtch->priv->profiles = NULL; + } G_OBJECT_CLASS (pulse_device_switch_parent_class)->dispose (object); } @@ -183,7 +189,7 @@ pulse_device_switch_add_profile (PulseDeviceSwitch *swtch, PulseDeviceProfile *p g_return_if_fail (PULSE_IS_DEVICE_PROFILE (profile)); swtch->priv->profiles = g_list_insert_sorted (swtch->priv->profiles, - profile, + g_object_ref (profile), compare_profiles); } |