qmlgl: don't critical on input events before input format has been set
authorMatthew Waters <matthew@centricular.com>
Fri, 27 Aug 2021 03:30:57 +0000 (13:30 +1000)
committerMatthew Waters <matthew@centricular.com>
Fri, 27 Aug 2021 03:34:01 +0000 (13:34 +1000)
Accessing the unset GstVideoInfo would result in criticals

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/1065>

ext/qt/qtitem.cc

index 31deedb..e042b2f 100644 (file)
@@ -353,6 +353,7 @@ QtGLVideoItem::mapPointToStreamSize(QPointF pos)
 
   stream_y = CLAMP(stream_y, 0., stream_height);
   GST_TRACE ("transform %fx%f into %fx%f", x, y, stream_x, stream_y);
+
   return QPointF(stream_x, stream_y);
 }
 
@@ -397,6 +398,13 @@ QtGLVideoItem::hoverMoveEvent(QHoverEvent * event)
   quint32 button = !!mousePressedButton;
 
   g_mutex_lock (&this->priv->lock);
+
+  /* can't do anything when we don't have input format */
+  if (!this->priv->negotiated) {
+    g_mutex_unlock (&this->priv->lock);
+    return;
+  }
+
   if (event->pos() != event->oldPos()) {
     QPointF pos = mapPointToStreamSize(event->pos());
     GstElement *element = GST_ELEMENT_CAST (g_weak_ref_get (&this->priv->sink));
@@ -430,6 +438,12 @@ QtGLVideoItem::sendMouseEvent(QMouseEvent * event, const gchar * type)
 
   g_mutex_lock (&this->priv->lock);
 
+  /* can't do anything when we don't have input format */
+  if (!this->priv->negotiated) {
+    g_mutex_unlock (&this->priv->lock);
+    return;
+  }
+
   QPointF pos = mapPointToStreamSize(event->pos());
   gchar* event_type = g_strconcat ("mouse-button-", type, NULL);
   GstElement *element = GST_ELEMENT_CAST (g_weak_ref_get (&this->priv->sink));