Commit 2cafb9db authored by Daniel Vrátil's avatar Daniel Vrátil 🤖
Browse files

Only call QApplication::syncX() from the main thread

This fixes a regression introduced in 2db4c4. In order to pass WID to gstreamer
synchronously, a Qt::DirectConnection between Pipeline signal and a VideoWidget
slot must be created. However the signal from Pipeline can be emitted from an
arbitrary thread, so we can't call QApplication::syncX() directly from the slot
callchain. This patch moves the call to VideoWidget::syncX() slot that is called
from X11Renderer via queued invocation to make sure it's always executed from the
main thread.

FIXED-IN: 4.7.3
BUG: 327367
BUG: 332977
CCBUG: 305333
parent 57f22699
......@@ -18,6 +18,7 @@
#include "videowidget.h"
#include <QtCore/QEvent>
#include <QtCore/QThread>
#include <QtGui/QResizeEvent>
#include <QtGui/QPalette>
#include <QtGui/QImage>
......@@ -81,6 +82,18 @@ void VideoWidget::updateWindowID()
render->setOverlay();
}
void Gstreamer::VideoWidget::syncX()
{
Q_ASSERT(QThread::currentThread() == QApplication::instance()->thread());
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#warning syncx
// QApplication::syncX();
#else
QApplication::syncX();
#endif
}
void VideoWidget::finalizeLink()
{
connect(root()->pipeline(), SIGNAL(mouseOverActive(bool)), this, SLOT(mouseOverActive(bool)));
......
......@@ -87,6 +87,7 @@ public:
public slots:
void setMovieSize(const QSize &size);
void mouseOverActive(bool active);
void syncX();
protected:
virtual void keyPressEvent(QKeyEvent *event);
......
......@@ -162,14 +162,6 @@ void X11Renderer::setOverlay()
{
if (m_videoSink && GST_IS_X_OVERLAY(m_videoSink)) {
WId windowId = m_renderWidget->winId();
// Even if we have created a winId at this point, other X applications
// need to be aware of it.
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#warning syncx
// QApplication::syncX();
#else
QApplication::syncX();
#endif
#if GST_VERSION >= GST_VERSION_CHECK(0,10,31,0)
gst_x_overlay_set_window_handle(GST_X_OVERLAY(m_videoSink), windowId);
#else
......@@ -182,12 +174,11 @@ void X11Renderer::setOverlay()
void X11Renderer::windowExposed()
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#warning syncx
// QApplication::syncX();
#else
QApplication::syncX();
#endif
// This can be invoked within a callchain in an arbitrary thread, so make
// sure we call syncX() from the main thread
QMetaObject::invokeMethod(m_videoWidget, "syncX",
Qt::QueuedConnection);
if (m_videoSink && GST_IS_X_OVERLAY(m_videoSink))
gst_x_overlay_expose(GST_X_OVERLAY(m_videoSink));
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment