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.
This commit is contained in:
Rafał Dzięgiel
2025-01-22 20:26:48 +01:00
parent 0cee4e90a5
commit d3a169fccd

View File

@@ -977,20 +977,24 @@ _get_widget_from_video_sink (GstElement *vsink)
GParamSpec *pspec; GParamSpec *pspec;
if ((pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (vsink), "widget")) 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"); GST_DEBUG ("Video sink provides a widget");
g_object_get (vsink, "widget", &widget, NULL); g_object_get (vsink, "widget", &widget, NULL);
} else if ((pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (vsink), "paintable")) } else if ((pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (vsink), "paintable"))
&& pspec->value_type == GDK_TYPE_PAINTABLE) { && g_type_is_a (pspec->value_type, G_TYPE_OBJECT)) {
GdkPaintable *paintable = NULL; GObject *paintable = NULL;
GST_DEBUG ("Video sink provides a paintable"); GST_DEBUG ("Video sink provides a paintable");
g_object_get (vsink, "paintable", &paintable, NULL); g_object_get (vsink, "paintable", &paintable, NULL);
widget = g_object_ref_sink (gtk_picture_new ()); if (G_LIKELY (paintable != NULL)) {
gtk_picture_set_paintable (GTK_PICTURE (widget), paintable); 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; return widget;