From 172eaade07a24a9ab3f2dfc4750e1add05c02852 Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Mon, 1 Nov 2004 14:43:38 +0000 Subject: [PATCH] Fixes a bunch of problems with finalize and dispose functions, either assumptions that dispose is only called once, o... Original commit message from CVS: * ext/alsa/gstalsa.c: (gst_alsa_class_init), (gst_alsa_dispose), (gst_alsa_finalize): * ext/cdaudio/gstcdaudio.c: (gst_cdaudio_class_init), (gst_cdaudio_finalize): * ext/cdparanoia/gstcdparanoia.c: (cdparanoia_class_init), (cdparanoia_finalize): * ext/divx/gstdivxdec.c: (gst_divxdec_dispose): * ext/divx/gstdivxenc.c: (gst_divxenc_dispose): * ext/dvdread/dvdreadsrc.c: (dvdreadsrc_class_init), (dvdreadsrc_finalize): * ext/flac/gstflacdec.c: (gst_flacdec_class_init), (gst_flacdec_finalize): * ext/flac/gstflacenc.c: (gst_flacenc_class_init), (gst_flacenc_finalize): * ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_class_init), (gst_gnomevfssink_finalize): * ext/gnomevfs/gstgnomevfssrc.c: (gst_gnomevfssrc_class_init), (gst_gnomevfssrc_finalize): * ext/libfame/gstlibfame.c: (gst_fameenc_class_init), (gst_fameenc_finalize): * ext/nas/nassink.c: (gst_nassink_class_init), (gst_nassink_finalize): * ext/sdl/sdlvideosink.c: (gst_sdlvideosink_finalize), (gst_sdlvideosink_class_init): * ext/sndfile/gstsf.c: (gst_sf_dispose): * gst-libs/gst/mixer/mixertrack.c: (gst_mixer_track_dispose): * gst-libs/gst/tuner/tunerchannel.c: (gst_tuner_channel_dispose): * gst-libs/gst/tuner/tunernorm.c: (gst_tuner_norm_dispose): * gst-libs/gst/xwindowlistener/xwindowlistener.c: (gst_x_window_listener_dispose): * gst/audioscale/gstaudioscale.c: * gst/playondemand/gstplayondemand.c: (play_on_demand_class_init), (play_on_demand_finalize): * gst/videofilter/gstvideobalance.c: (gst_videobalance_dispose): * gst/videoscale/gstvideoscale.c: (gst_videoscale_chain): * sys/cdrom/gstcdplayer.c: (cdplayer_class_init), (cdplayer_finalize): * sys/glsink/glimagesink.c: (gst_glimagesink_finalize), (gst_glimagesink_class_init): * sys/oss/gstosselement.c: (gst_osselement_class_init), (gst_osselement_finalize): * sys/oss/gstosssink.c: (gst_osssink_dispose): * sys/oss/gstosssrc.c: (gst_osssrc_dispose): * sys/v4l/gstv4lelement.c: (gst_v4lelement_dispose): Fixes a bunch of problems with finalize and dispose functions, either assumptions that dispose is only called once, or not calling the parent class dispose/finalize function --- ChangeLog | 49 +++++++++++++++++++ ext/cdaudio/gstcdaudio.c | 13 ++--- ext/divx/gstdivxdec.c | 4 +- ext/divx/gstdivxenc.c | 1 + ext/libfame/gstlibfame.c | 10 ++-- ext/nas/nassink.c | 7 +-- ext/sdl/sdlvideosink.c | 8 +-- ext/sndfile/gstsf.c | 5 +- gst-libs/gst/mixer/mixertrack.c | 4 +- gst-libs/gst/tuner/tunerchannel.c | 4 +- gst-libs/gst/tuner/tunernorm.c | 4 +- .../gst/xwindowlistener/xwindowlistener.c | 1 + gst/playondemand/gstplayondemand.c | 10 ++-- sys/cdrom/gstcdplayer.c | 12 ++--- sys/glsink/glimagesink.c | 8 +-- 15 files changed, 98 insertions(+), 42 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0b6aaad27f..8c8d033aad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,52 @@ +2004-11-02 Jan Schmidt + * ext/alsa/gstalsa.c: (gst_alsa_class_init), (gst_alsa_dispose), + (gst_alsa_finalize): + * ext/cdaudio/gstcdaudio.c: (gst_cdaudio_class_init), + (gst_cdaudio_finalize): + * ext/cdparanoia/gstcdparanoia.c: (cdparanoia_class_init), + (cdparanoia_finalize): + * ext/divx/gstdivxdec.c: (gst_divxdec_dispose): + * ext/divx/gstdivxenc.c: (gst_divxenc_dispose): + * ext/dvdread/dvdreadsrc.c: (dvdreadsrc_class_init), + (dvdreadsrc_finalize): + * ext/flac/gstflacdec.c: (gst_flacdec_class_init), + (gst_flacdec_finalize): + * ext/flac/gstflacenc.c: (gst_flacenc_class_init), + (gst_flacenc_finalize): + * ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_class_init), + (gst_gnomevfssink_finalize): + * ext/gnomevfs/gstgnomevfssrc.c: (gst_gnomevfssrc_class_init), + (gst_gnomevfssrc_finalize): + * ext/libfame/gstlibfame.c: (gst_fameenc_class_init), + (gst_fameenc_finalize): + * ext/nas/nassink.c: (gst_nassink_class_init), + (gst_nassink_finalize): + * ext/sdl/sdlvideosink.c: (gst_sdlvideosink_finalize), + (gst_sdlvideosink_class_init): + * ext/sndfile/gstsf.c: (gst_sf_dispose): + * gst-libs/gst/mixer/mixertrack.c: (gst_mixer_track_dispose): + * gst-libs/gst/tuner/tunerchannel.c: (gst_tuner_channel_dispose): + * gst-libs/gst/tuner/tunernorm.c: (gst_tuner_norm_dispose): + * gst-libs/gst/xwindowlistener/xwindowlistener.c: + (gst_x_window_listener_dispose): + * gst/audioscale/gstaudioscale.c: + * gst/playondemand/gstplayondemand.c: (play_on_demand_class_init), + (play_on_demand_finalize): + * gst/videofilter/gstvideobalance.c: (gst_videobalance_dispose): + * gst/videoscale/gstvideoscale.c: (gst_videoscale_chain): + * sys/cdrom/gstcdplayer.c: (cdplayer_class_init), + (cdplayer_finalize): + * sys/glsink/glimagesink.c: (gst_glimagesink_finalize), + (gst_glimagesink_class_init): + * sys/oss/gstosselement.c: (gst_osselement_class_init), + (gst_osselement_finalize): + * sys/oss/gstosssink.c: (gst_osssink_dispose): + * sys/oss/gstosssrc.c: (gst_osssrc_dispose): + * sys/v4l/gstv4lelement.c: (gst_v4lelement_dispose): + Fixes a bunch of problems with finalize and dispose functions, + either assumptions that dispose is only called once, or not calling + the parent class dispose/finalize function + 2004-11-01 Stefan Kost * ext/esd/esdsink.c: (gst_esdsink_init), (gst_esdsink_link): diff --git a/ext/cdaudio/gstcdaudio.c b/ext/cdaudio/gstcdaudio.c index 9bf7fddd19..069191f4f4 100644 --- a/ext/cdaudio/gstcdaudio.c +++ b/ext/cdaudio/gstcdaudio.c @@ -83,7 +83,7 @@ enum static void gst_cdaudio_class_init (GstCDAudioClass * klass); static void gst_cdaudio_init (GstCDAudio * cdaudio); -static void gst_cdaudio_dispose (GObject * object); +static void gst_cdaudio_finalize (GObject * object); static void gst_cdaudio_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * spec); @@ -185,7 +185,7 @@ gst_cdaudio_class_init (GstCDAudioClass * klass) G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstCDAudioClass, track_change), NULL, NULL, gst_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT); - gobject_klass->dispose = GST_DEBUG_FUNCPTR (gst_cdaudio_dispose); + gobject_klass->finalize = GST_DEBUG_FUNCPTR (gst_cdaudio_finalize); gstelement_klass->change_state = GST_DEBUG_FUNCPTR (gst_cdaudio_change_state); gstelement_klass->get_event_masks = @@ -210,17 +210,14 @@ gst_cdaudio_init (GstCDAudio * cdaudio) } static void -gst_cdaudio_dispose (GObject * object) +gst_cdaudio_finalize (GObject * object) { - GstCDAudio *cdaudio; + GstCDAudio *cdaudio = GST_CDAUDIO (object); - cdaudio = GST_CDAUDIO (object); g_timer_destroy (cdaudio->timer); g_free (cdaudio->device); - if (G_OBJECT_CLASS (parent_class)->dispose) { - G_OBJECT_CLASS (parent_class)->dispose (object); - } + G_OBJECT_CLASS (parent_class)->finalize (object); } static void diff --git a/ext/divx/gstdivxdec.c b/ext/divx/gstdivxdec.c index 0a3e7ad864..543bff3f9b 100644 --- a/ext/divx/gstdivxdec.c +++ b/ext/divx/gstdivxdec.c @@ -255,6 +255,7 @@ gst_divxdec_dispose (GObject * object) GstDivxDec *divxdec = GST_DIVXDEC (object); gst_divxdec_unset (divxdec); + G_OBJECT_CLASS (parent_class)->dispose (object); } @@ -397,8 +398,7 @@ gst_divxdec_negotiate (GstDivxDec * divxdec) guint32 csp; gint bitcnt; } - fmt_list[] = - { + fmt_list[] = { { GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'), 16, 16, GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'), 0} diff --git a/ext/divx/gstdivxenc.c b/ext/divx/gstdivxenc.c index 3f3819300c..c944c18a70 100644 --- a/ext/divx/gstdivxenc.c +++ b/ext/divx/gstdivxenc.c @@ -310,6 +310,7 @@ gst_divxenc_dispose (GObject * object) GstDivxEnc *divxenc = GST_DIVXENC (object); gst_divxenc_unset (divxenc); + G_OBJECT_CLASS (parent_class)->dispose (object); } diff --git a/ext/libfame/gstlibfame.c b/ext/libfame/gstlibfame.c index a5a5527828..5024bb122c 100644 --- a/ext/libfame/gstlibfame.c +++ b/ext/libfame/gstlibfame.c @@ -132,7 +132,7 @@ framerate_to_index (gfloat fps) static void gst_fameenc_class_init (GstFameEncClass * klass); static void gst_fameenc_base_init (GstFameEncClass * klass); static void gst_fameenc_init (GstFameEnc * fameenc); -static void gst_fameenc_dispose (GObject * object); +static void gst_fameenc_finalize (GObject * object); static void gst_fameenc_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); @@ -205,7 +205,7 @@ gst_fameenc_class_init (GstFameEncClass * klass) gobject_class->set_property = gst_fameenc_set_property; gobject_class->get_property = gst_fameenc_get_property; - gobject_class->dispose = gst_fameenc_dispose; + gobject_class->finalize = gst_fameenc_finalize; fame_object_name = g_quark_from_string ("GstFameObjectName"); @@ -402,13 +402,13 @@ gst_fameenc_init (GstFameEnc * fameenc) } static void -gst_fameenc_dispose (GObject * object) +gst_fameenc_finalize (GObject * object) { GstFameEnc *fameenc = GST_FAMEENC (object); - G_OBJECT_CLASS (parent_class)->dispose (object); - g_free (fameenc->buffer); + + G_OBJECT_CLASS (parent_class)->finalize (object); } static void diff --git a/ext/nas/nassink.c b/ext/nas/nassink.c index f9b67a2048..264c891c11 100644 --- a/ext/nas/nassink.c +++ b/ext/nas/nassink.c @@ -67,7 +67,7 @@ static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink", static void gst_nassink_base_init (gpointer g_class); static void gst_nassink_class_init (GstNassinkClass * klass); static void gst_nassink_init (GstNassink * nassink); -static void gst_nassink_dispose (GObject * object); +static void gst_nassink_finalize (GObject * object); static gboolean gst_nassink_open_audio (GstNassink * sink); static void gst_nassink_close_audio (GstNassink * sink); @@ -153,7 +153,7 @@ gst_nassink_class_init (GstNassinkClass * klass) gobject_class->set_property = gst_nassink_set_property; gobject_class->get_property = gst_nassink_get_property; - gobject_class->dispose = gst_nassink_dispose; + gobject_class->finalize = gst_nassink_finalize; g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MUTE, g_param_spec_boolean ("mute", "mute", "mute", TRUE, G_PARAM_READWRITE)); /* CHECKME */ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_HOST, g_param_spec_string ("host", "host", "host", NULL, G_PARAM_READWRITE)); /* CHECKME */ @@ -190,11 +190,12 @@ gst_nassink_init (GstNassink * nassink) } static void -gst_nassink_dispose (GObject * object) +gst_nassink_finalize (GObject * object) { GstNassink *nassink = GST_NASSINK (object); g_free (nassink->host); + G_OBJECT_CLASS (parent_class)->finalize (object); } static GstCaps * diff --git a/ext/sdl/sdlvideosink.c b/ext/sdl/sdlvideosink.c index c08bf2d14a..0d8c719c35 100644 --- a/ext/sdl/sdlvideosink.c +++ b/ext/sdl/sdlvideosink.c @@ -150,12 +150,12 @@ gst_sdlvideosink_base_init (gpointer g_class) } static void -gst_sdlvideosink_dispose (GObject * obj) +gst_sdlvideosink_finalize (GObject * obj) { g_mutex_free (GST_SDLVIDEOSINK (obj)->lock); - if (((GObjectClass *) parent_class)->dispose) - ((GObjectClass *) parent_class)->dispose (obj); + if (((GObjectClass *) parent_class)->finalize) + ((GObjectClass *) parent_class)->finalize (obj); } static void @@ -173,7 +173,7 @@ gst_sdlvideosink_class_init (GstSDLVideoSinkClass * klass) gobject_class->set_property = gst_sdlvideosink_set_property; gobject_class->get_property = gst_sdlvideosink_get_property; - gobject_class->dispose = gst_sdlvideosink_dispose; + gobject_class->finalize = gst_sdlvideosink_finalize; gstelement_class->change_state = gst_sdlvideosink_change_state; diff --git a/ext/sndfile/gstsf.c b/ext/sndfile/gstsf.c index d48e2d4f1c..7a83e06767 100644 --- a/ext/sndfile/gstsf.c +++ b/ext/sndfile/gstsf.c @@ -327,7 +327,10 @@ gst_sf_dispose (GObject * object) { GstSF *this = (GstSF *) object; - gst_object_unparent (GST_OBJECT (this->provided_clock)); + if (this->provided_clock) { + gst_object_unparent (GST_OBJECT (this->provided_clock)); + this->provided_clock = NULL; + } G_OBJECT_CLASS (parent_class)->dispose (object); } diff --git a/gst-libs/gst/mixer/mixertrack.c b/gst-libs/gst/mixer/mixertrack.c index ea531d5f3b..36ce288d4a 100644 --- a/gst-libs/gst/mixer/mixertrack.c +++ b/gst-libs/gst/mixer/mixertrack.c @@ -183,8 +183,10 @@ gst_mixer_track_dispose (GObject * object) { GstMixerTrack *channel = GST_MIXER_TRACK (object); - if (channel->label) + if (channel->label) { g_free (channel->label); + channel->label = NULL; + } if (parent_class->dispose) parent_class->dispose (object); diff --git a/gst-libs/gst/tuner/tunerchannel.c b/gst-libs/gst/tuner/tunerchannel.c index de0be2e433..1826a3e27b 100644 --- a/gst-libs/gst/tuner/tunerchannel.c +++ b/gst-libs/gst/tuner/tunerchannel.c @@ -104,8 +104,10 @@ gst_tuner_channel_dispose (GObject * object) { GstTunerChannel *channel = GST_TUNER_CHANNEL (object); - if (channel->label) + if (channel->label) { g_free (channel->label); + channel->label = NULL; + } if (parent_class->dispose) parent_class->dispose (object); diff --git a/gst-libs/gst/tuner/tunernorm.c b/gst-libs/gst/tuner/tunernorm.c index 8fb98db7d4..2eb973de8d 100644 --- a/gst-libs/gst/tuner/tunernorm.c +++ b/gst-libs/gst/tuner/tunernorm.c @@ -88,8 +88,10 @@ gst_tuner_norm_dispose (GObject * object) { GstTunerNorm *norm = GST_TUNER_NORM (object); - if (norm->label) + if (norm->label) { g_free (norm->label); + norm->label = NULL; + } if (parent_class->dispose) parent_class->dispose (object); diff --git a/gst-libs/gst/xwindowlistener/xwindowlistener.c b/gst-libs/gst/xwindowlistener/xwindowlistener.c index 9963535c2b..ebbc9ac606 100644 --- a/gst-libs/gst/xwindowlistener/xwindowlistener.c +++ b/gst-libs/gst/xwindowlistener/xwindowlistener.c @@ -96,6 +96,7 @@ gst_x_window_listener_dispose (GObject * object) if (xwin->display_name) { g_free (xwin->display_name); + xwin->display_name = NULL; } if (parent_class->dispose) { diff --git a/gst/playondemand/gstplayondemand.c b/gst/playondemand/gstplayondemand.c index f9e049c054..fdfe09b5a4 100644 --- a/gst/playondemand/gstplayondemand.c +++ b/gst/playondemand/gstplayondemand.c @@ -74,7 +74,7 @@ static void play_on_demand_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); static void play_on_demand_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); -static void play_on_demand_dispose (GObject * object); +static void play_on_demand_finalize (GObject * object); /* GStreamer functionality */ static GstPadLinkReturn play_on_demand_pad_link (GstPad * pad, @@ -198,7 +198,7 @@ play_on_demand_class_init (GstPlayOnDemandClass * klass) gobject_class->set_property = play_on_demand_set_property; gobject_class->get_property = play_on_demand_get_property; - gobject_class->dispose = play_on_demand_dispose; + gobject_class->finalize = play_on_demand_finalize; gstelement_class->set_clock = play_on_demand_set_clock; @@ -367,15 +367,15 @@ play_on_demand_get_property (GObject * object, guint prop_id, } static void -play_on_demand_dispose (GObject * object) +play_on_demand_finalize (GObject * object) { GstPlayOnDemand *filter = GST_PLAYONDEMAND (object); - G_OBJECT_CLASS (parent_class)->dispose (object); - g_free (filter->ticks); g_free (filter->plays); g_free (filter->buffer); + + G_OBJECT_CLASS (parent_class)->finalize (object); } static GstPadLinkReturn diff --git a/sys/cdrom/gstcdplayer.c b/sys/cdrom/gstcdplayer.c index 99c55b7719..bf3b37b5cb 100644 --- a/sys/cdrom/gstcdplayer.c +++ b/sys/cdrom/gstcdplayer.c @@ -44,7 +44,7 @@ enum static void cdplayer_base_init (gpointer g_class); static void cdplayer_class_init (CDPlayerClass * klass); static void cdplayer_init (CDPlayer * cdp); -static void cdplayer_dispose (GObject * object); +static void cdplayer_finalize (GObject * object); static void cdplayer_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * spec); @@ -110,7 +110,7 @@ cdplayer_class_init (CDPlayerClass * klass) parent_class = g_type_class_ref (gst_bin_get_type ()); - gobject_klass->dispose = GST_DEBUG_FUNCPTR (cdplayer_dispose); + gobject_klass->finalize = GST_DEBUG_FUNCPTR (cdplayer_finalize); gstelement_klass->change_state = GST_DEBUG_FUNCPTR (cdplayer_change_state); gstbin_klass->iterate = GST_DEBUG_FUNCPTR (cdplayer_iterate); @@ -235,7 +235,7 @@ cdplayer_get_property (GObject * object, guint prop_id, GValue * value, } static void -cdplayer_dispose (GObject * object) +cdplayer_finalize (GObject * object) { CDPlayer *cdp; @@ -244,11 +244,9 @@ cdplayer_dispose (GObject * object) cdp = CDPLAYER (object); g_free (cdp->device); - if (G_OBJECT_CLASS (parent_class)->dispose) { - G_OBJECT_CLASS (parent_class)->dispose (object); + if (G_OBJECT_CLASS (parent_class)->finalize) { + G_OBJECT_CLASS (parent_class)->finalize (object); } - - return; } static gboolean diff --git a/sys/glsink/glimagesink.c b/sys/glsink/glimagesink.c index b40406c530..e94bf1ae43 100644 --- a/sys/glsink/glimagesink.c +++ b/sys/glsink/glimagesink.c @@ -648,7 +648,7 @@ static int attrListDouble[] = { }; /* This function get the X Display and global infos about it. Everything is - stored in our object and will be cleaned when the object is disposed. Note + stored in our object and will be cleaned when the object is finalized. Note here that caps for supported format are generated without any window or image creation */ static GstXContext * @@ -1410,7 +1410,7 @@ gst_glimagesink_get_property (GObject * object, guint prop_id, } static void -gst_glimagesink_dispose (GObject * object) +gst_glimagesink_finalize (GObject * object) { GstGLImageSink *glimagesink; @@ -1424,7 +1424,7 @@ gst_glimagesink_dispose (GObject * object) g_mutex_free (glimagesink->x_lock); g_mutex_free (glimagesink->pool_lock); - G_OBJECT_CLASS (parent_class)->dispose (object); + G_OBJECT_CLASS (parent_class)->finalize (object); } static void @@ -1521,7 +1521,7 @@ gst_glimagesink_class_init (GstGLImageSinkClass * klass) gst_marshal_VOID__POINTER_OBJECT, G_TYPE_NONE, 2, GST_TYPE_BUFFER, GST_TYPE_PAD); - gobject_class->dispose = gst_glimagesink_dispose; + gobject_class->finalize = gst_glimagesink_finalize; gobject_class->set_property = gst_glimagesink_set_property; gobject_class->get_property = gst_glimagesink_get_property;