From b71b7dc9e60bc37a5143310b1bf00658de9a7a8b Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Wed, 17 Jun 2015 09:36:40 -0400 Subject: [PATCH] GstGtkGLSink: Post error if widget gets destroyed https://bugzilla.gnome.org/show_bug.cgi?id=751104 --- ext/gtk/gstgtkglsink.c | 14 ++++++++++++++ ext/gtk/gstgtkglsink.h | 1 + 2 files changed, 15 insertions(+) diff --git a/ext/gtk/gstgtkglsink.c b/ext/gtk/gstgtkglsink.c index cee44ba6a2..6f7c2b5c3f 100644 --- a/ext/gtk/gstgtkglsink.c +++ b/ext/gtk/gstgtkglsink.c @@ -161,6 +161,12 @@ gst_gtk_gl_sink_finalize (GObject * object) G_OBJECT_CLASS (parent_class)->finalize (object); } +static void +widget_destroy_cb (GtkWidget * widget, GstGtkGLSink * gtk_sink) +{ + g_atomic_int_set (>k_sink->widget_destroyed, 1); +} + static GtkGstGLWidget * gst_gtk_gl_sink_get_widget (GstGtkGLSink * gtk_sink) { @@ -188,6 +194,8 @@ gst_gtk_gl_sink_get_widget (GstGtkGLSink * gtk_sink) /* Take the floating ref, otherwise the destruction of the container will * make this widget disapear possibly before we are done. */ gst_object_ref_sink (gtk_sink->widget); + g_signal_connect (gtk_sink->widget, "destroy", + G_CALLBACK (widget_destroy_cb), gtk_sink); return gtk_sink->widget; } @@ -426,6 +434,12 @@ gst_gtk_gl_sink_show_frame (GstVideoSink * vsink, GstBuffer * buf) gtk_gst_gl_widget_set_buffer (gtk_sink->widget, buf); + if (g_atomic_int_get (>k_sink->widget_destroyed)) { + GST_ELEMENT_ERROR (gtk_sink, RESOURCE, NOT_FOUND, + ("%s", "Output widget was destroyed"), (NULL)); + return GST_FLOW_ERROR; + } + return GST_FLOW_OK; } diff --git a/ext/gtk/gstgtkglsink.h b/ext/gtk/gstgtkglsink.h index 844b28bd3f..4944ce6d35 100644 --- a/ext/gtk/gstgtkglsink.h +++ b/ext/gtk/gstgtkglsink.h @@ -54,6 +54,7 @@ struct _GstGtkGLSink GstVideoSink parent; GtkGstGLWidget *widget; + gboolean widget_destroyed; GstVideoInfo v_info; GstBufferPool *pool;