diff options
author | Adric Blake <[email protected]> | 2023-09-01 21:30:19 -0400 |
---|---|---|
committer | raveit65 <[email protected]> | 2023-09-18 12:07:43 +0200 |
commit | e9995a70b1ff951cca3471894db2c289d9b0e4f9 (patch) | |
tree | 87ff8e92b3d868bf0c1afb696bedf38c4556d5cb /libmatemixer/matemixer-stream-switch.c | |
parent | 83021fd2d62601a3ea66e8d7bad28856ee3102db (diff) | |
download | libmatemixer-e9995a70b1ff951cca3471894db2c289d9b0e4f9.tar.bz2 libmatemixer-e9995a70b1ff951cca3471894db2c289d9b0e4f9.tar.xz |
Remove weak pointers on dispose
A weak pointer has a callback that will happily overwrite freed object memory if the weakly referenced object outlives the object storing the reference. Remove those callbacks when they are no longer needed.
Diffstat (limited to 'libmatemixer/matemixer-stream-switch.c')
-rw-r--r-- | libmatemixer/matemixer-stream-switch.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/libmatemixer/matemixer-stream-switch.c b/libmatemixer/matemixer-stream-switch.c index 814918d..cfb74c8 100644 --- a/libmatemixer/matemixer-stream-switch.c +++ b/libmatemixer/matemixer-stream-switch.c @@ -55,6 +55,8 @@ static void mate_mixer_stream_switch_set_property (GObject *o const GValue *value, GParamSpec *pspec); +static void mate_mixer_stream_switch_dispose (GObject *object); + G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (MateMixerStreamSwitch, mate_mixer_stream_switch, MATE_MIXER_TYPE_SWITCH) static void @@ -63,6 +65,7 @@ mate_mixer_stream_switch_class_init (MateMixerStreamSwitchClass *klass) GObjectClass *object_class; object_class = G_OBJECT_CLASS (klass); + object_class->dispose = mate_mixer_stream_switch_dispose; object_class->get_property = mate_mixer_stream_switch_get_property; object_class->set_property = mate_mixer_stream_switch_set_property; @@ -161,6 +164,20 @@ mate_mixer_stream_switch_init (MateMixerStreamSwitch *swtch) swtch->priv = mate_mixer_stream_switch_get_instance_private (swtch); } +static void +mate_mixer_stream_switch_dispose (GObject *object) +{ + MateMixerStreamSwitch *swtch; + + swtch = MATE_MIXER_STREAM_SWITCH (object); + + if (swtch->priv->stream != NULL) + g_object_remove_weak_pointer(G_OBJECT (swtch->priv->stream), + (gpointer *) &swtch->priv->stream); + + G_OBJECT_CLASS (mate_mixer_stream_switch_parent_class)->dispose (object); +} + /** * mate_mixer_stream_switch_get_flags: * @swtch: a #MateMixerStreamSwitch |