From d3a169fccdff38147f8c438a1ff9253e58d5c155 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Wed, 22 Jan 2025 20:26:48 +0100 Subject: [PATCH] clapper-gtk: video: Fix sink property type checks Sometimes property might return a subclass type when object is subclassed. This especially happens with custom GdkPaintable implementations. For this reason instead of comparing object type, check if it inherits what we want. --- src/lib/clapper-gtk/clapper-gtk-video.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/lib/clapper-gtk/clapper-gtk-video.c b/src/lib/clapper-gtk/clapper-gtk-video.c index 2ca53279..ba011c32 100644 --- a/src/lib/clapper-gtk/clapper-gtk-video.c +++ b/src/lib/clapper-gtk/clapper-gtk-video.c @@ -977,20 +977,24 @@ _get_widget_from_video_sink (GstElement *vsink) GParamSpec *pspec; if ((pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (vsink), "widget")) - && pspec->value_type == GTK_TYPE_WIDGET) { + && g_type_is_a (pspec->value_type, GTK_TYPE_WIDGET)) { GST_DEBUG ("Video sink provides a widget"); g_object_get (vsink, "widget", &widget, NULL); } else if ((pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (vsink), "paintable")) - && pspec->value_type == GDK_TYPE_PAINTABLE) { - GdkPaintable *paintable = NULL; + && g_type_is_a (pspec->value_type, G_TYPE_OBJECT)) { + GObject *paintable = NULL; GST_DEBUG ("Video sink provides a paintable"); g_object_get (vsink, "paintable", &paintable, NULL); - widget = g_object_ref_sink (gtk_picture_new ()); - gtk_picture_set_paintable (GTK_PICTURE (widget), paintable); + if (G_LIKELY (paintable != NULL)) { + if (GDK_IS_PAINTABLE (paintable)) { + widget = g_object_ref_sink (gtk_picture_new ()); + gtk_picture_set_paintable (GTK_PICTURE (widget), GDK_PAINTABLE (paintable)); + } - g_object_unref (paintable); + g_object_unref (paintable); + } } return widget;