From 55e04d129f10281a8b0a9675d72ff34eabbf8a62 Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Mon, 15 Nov 2021 14:39:14 +1100 Subject: [PATCH] qmlglsink: fix another resize case If qt asks us to redraw before we have both set a buffer and caps we would attempt to use the new caps with the old buffer which could result in bad things happening. Only update caps from new_caps once the buffer has actually been set. Part-of: --- subprojects/gst-plugins-good/ext/qt/qtitem.cc | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/subprojects/gst-plugins-good/ext/qt/qtitem.cc b/subprojects/gst-plugins-good/ext/qt/qtitem.cc index 0bc5896733..a5a548fc09 100644 --- a/subprojects/gst-plugins-good/ext/qt/qtitem.cc +++ b/subprojects/gst-plugins-good/ext/qt/qtitem.cc @@ -285,19 +285,6 @@ QtGLVideoItem::updatePaintNode(QSGNode * oldNode, GST_TRACE ("%p updatePaintNode", this); - if (this->priv->new_caps) { - GST_DEBUG ("%p caps change from %" GST_PTR_FORMAT " to %" GST_PTR_FORMAT, - this, this->priv->caps, this->priv->new_caps); - gst_caps_take (&this->priv->caps, this->priv->new_caps); - this->priv->new_caps = NULL; - this->priv->v_info = this->priv->new_v_info; - - if (!_calculate_par (this, &this->priv->v_info)) { - g_mutex_unlock (&this->priv->lock); - return NULL; - } - } - if (!this->priv->caps) { GST_LOG ("%p no caps yet", this); g_mutex_unlock (&this->priv->lock); @@ -580,6 +567,19 @@ QtGLVideoItemInterface::setBuffer (GstBuffer * buffer) g_mutex_lock (&qt_item->priv->lock); + if (qt_item->priv->new_caps) { + GST_DEBUG ("%p caps change from %" GST_PTR_FORMAT " to %" GST_PTR_FORMAT, + this, qt_item->priv->caps, qt_item->priv->new_caps); + gst_caps_take (&qt_item->priv->caps, qt_item->priv->new_caps); + qt_item->priv->new_caps = NULL; + qt_item->priv->v_info = qt_item->priv->new_v_info; + + if (!_calculate_par (qt_item, &qt_item->priv->v_info)) { + g_mutex_unlock (&qt_item->priv->lock); + return; + } + } + gst_buffer_replace (&qt_item->priv->buffer, buffer); QMetaObject::invokeMethod(qt_item, "update", Qt::QueuedConnection);