From e050541f11711d2ff8edf4b80213acffbdba7a07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=B6ran=20J=C3=B6nsson?= Date: Mon, 23 Jun 2014 11:53:11 +0200 Subject: [PATCH] watchdog: Only create a new GSource if we have a main context We can still get OOB events while stopping the watchdog element, and while stopping it we destroy the main context. Also let the GSource own a reference to the element for additional safety. https://bugzilla.gnome.org/show_bug.cgi?id=732554 --- gst/debugutils/gstwatchdog.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gst/debugutils/gstwatchdog.c b/gst/debugutils/gstwatchdog.c index e844af79f5..eb77765f34 100644 --- a/gst/debugutils/gstwatchdog.c +++ b/gst/debugutils/gstwatchdog.c @@ -215,10 +215,10 @@ gst_watchdog_feed (GstWatchdog * watchdog) watchdog->source = NULL; } - if (watchdog->timeout != 0) { + if (watchdog->timeout != 0 && watchdog->main_context) { watchdog->source = g_timeout_source_new (watchdog->timeout); - g_source_set_callback (watchdog->source, gst_watchdog_trigger, watchdog, - NULL); + g_source_set_callback (watchdog->source, gst_watchdog_trigger, gst_object_ref (watchdog), + gst_object_unref); g_source_attach (watchdog->source, watchdog->main_context); } }