GstGtkGLSink: Post error if widget gets destroyed
authorXavier Claessens <xavier.claessens@collabora.com>
Wed, 17 Jun 2015 13:36:40 +0000 (09:36 -0400)
committerMatthew Waters <matthew@centricular.com>
Thu, 9 Jul 2015 06:40:19 +0000 (16:40 +1000)
https://bugzilla.gnome.org/show_bug.cgi?id=751104

ext/gtk/gstgtkglsink.c
ext/gtk/gstgtkglsink.h

index cee44ba..6f7c2b5 100644 (file)
@@ -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 (&gtk_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 (&gtk_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;
 }
 
index 844b28b..4944ce6 100644 (file)
@@ -54,6 +54,7 @@ struct _GstGtkGLSink
   GstVideoSink          parent;
 
   GtkGstGLWidget       *widget;
+  gboolean              widget_destroyed;
 
   GstVideoInfo          v_info;
   GstBufferPool        *pool;