From 1e7c085791dc60dbeb4872117a0366cbf95deb39 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Tue, 11 Jul 2023 17:00:57 +0200 Subject: [PATCH] gtk: Fix critical caused by pointer movement when stream is getting ready This check fixes a critical warning that can happen when a pointer motion happens and the video doesn't have its width/height information available. GStreamer-Video-CRITICAL **: gst_video_center_rect: assertion 'src->h != 0' failed #0 g_logv (log_domain=0x7ffff705e176 "GStreamer-Video", log_level=G_LOG_LEVEL_CRITICAL, format=, args=) at ../../../../Projects/jhbuild/glib/glib/gmessages.c:1422 #1 0x00007ffff7e1a81d in g_log (log_domain=, log_level=log_level@entry=G_LOG_LEVEL_CRITICAL, format=format@entry=0x7ffff7e77a9d "%s: assertion '%s' failed") at ../../../../Projects/jhbuild/glib/glib/gmessages.c:1460 #2 0x00007ffff7e1b749 in g_return_if_fail_warning (log_domain=, pretty_function=, expression=) at ../../../../Projects/jhbuild/glib/glib/gmessages.c:2930 #3 0x00007ffff701d90b in gst_video_sink_center_rect (src=..., dst=..., result=result@entry=0x7fffffffc6d0, scaling=scaling@entry=1) at ../../../../Projects/jhbuild/gstreamer/subprojects/gst-plugins-base/gst-libs/gst/video/gstvideosink.c:105 #4 0x00007fffe5652dbb in _fit_stream_to_allocated_size (result=0x7fffffffc6d0, allocation=0x7fffffffc6c0, base_widget=0x9396f0) at ../../../../Projects/jhbuild/gstreamer/subprojects/gst-plugins-good/ext/gtk/gtkgstbasewidget.c:326 #5 gtk_gst_base_widget_display_size_to_stream_size (base_widget=base_widget@entry=0x9396f0, x=1207.7109375, y=811.84765625, stream_x=stream_x@entry=0x7fffffffc720, stream_y=stream_y@entry=0x7fffffffc728) at ../../../../Projects/jhbuild/gstreamer/subprojects/gst-plugins-good/ext/gtk/gtkgstbasewidget.c:344 #6 0x00007fffe5651a4b in gst_gtk_base_sink_navigation_send_event (navigation=0x5ff990, event=0x178a730) at ../../../../Projects/jhbuild/gstreamer/subprojects/gst-plugins-good/ext/gtk/gstgtkbasesink.c:340 #7 0x00007fffe5652432 in gtk_gst_base_widget_motion_event (widget=, event=event@entry=0x1f14b60) at ../../../../Projects/jhbuild/gstreamer/subprojects/gst-plugins-good/ext/gtk/gtkgstbasewidget.c:404 Part-of: --- subprojects/gst-plugins-good/ext/gtk/gtkgstbasewidget.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/subprojects/gst-plugins-good/ext/gtk/gtkgstbasewidget.c b/subprojects/gst-plugins-good/ext/gtk/gtkgstbasewidget.c index ed7cfa66094..96addf2b5e1 100644 --- a/subprojects/gst-plugins-good/ext/gtk/gtkgstbasewidget.c +++ b/subprojects/gst-plugins-good/ext/gtk/gtkgstbasewidget.c @@ -323,7 +323,8 @@ _fit_stream_to_allocated_size (GtkGstBaseWidget * base_widget, dst.w = allocation->width; dst.h = allocation->height; - gst_video_sink_center_rect (src, dst, result, TRUE); + if (base_widget->display_width > 0 && base_widget->display_height > 0) + gst_video_sink_center_rect (src, dst, result, TRUE); } else { result->x = 0; result->y = 0;