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
This commit is contained in:
Göran Jönsson 2014-06-23 11:53:11 +02:00 committed by Sebastian Dröge
parent 2a7c05592d
commit e050541f11

View file

@ -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);
}
}