diff options
author | Andy Nichols <andy.nichols@digia.com> | 2012-10-08 17:37:44 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-10-09 13:46:31 +0200 |
commit | bc7e9fe7c7a42e1cad7572b85982e1ce73f80dd1 (patch) | |
tree | 2747089e9108236f70f880ee6dc994c2c663788e /src/imports/multimedia/qdeclarativevideooutput_render.cpp | |
parent | 13ce3d921a9fa6f920433ee7b5beb6f71c784334 (diff) |
Fix issue sharing OpenGL context from render thread on OS X
On OS X when running in QtQuick 2 examples in debug mode we fail an
assert because we try to set a dynamic property using
QObject::setProperty from the render thread, while the object exists in
the main thread. Now we call setProperty from the correct thread.
Change-Id: I3f26ead0f68fadcded472bf5c9014a4025f0a03e
Reviewed-by: Christian Stromme <christian.stromme@digia.com>
Reviewed-by: Jason Barron <jason.barron@digia.com>
Diffstat (limited to 'src/imports/multimedia/qdeclarativevideooutput_render.cpp')
-rw-r--r-- | src/imports/multimedia/qdeclarativevideooutput_render.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/imports/multimedia/qdeclarativevideooutput_render.cpp b/src/imports/multimedia/qdeclarativevideooutput_render.cpp index b74898f90..f65e0512c 100644 --- a/src/imports/multimedia/qdeclarativevideooutput_render.cpp +++ b/src/imports/multimedia/qdeclarativevideooutput_render.cpp @@ -171,7 +171,7 @@ QSGNode *QDeclarativeVideoRendererBackend::updatePaintNode(QSGNode *oldNode, if (!m_glContext) { m_glContext = QOpenGLContext::currentContext(); - m_surface->setProperty("GLContext", QVariant::fromValue<QObject*>(m_glContext)); + m_surface->scheduleOpenGLContextUpdate(); } if (m_frameChanged) { @@ -223,6 +223,11 @@ QAbstractVideoSurface *QDeclarativeVideoRendererBackend::videoSurface() const return m_surface; } +QOpenGLContext *QDeclarativeVideoRendererBackend::glContext() const +{ + return m_glContext; +} + void QDeclarativeVideoRendererBackend::present(const QVideoFrame &frame) { m_frameMutex.lock(); @@ -287,4 +292,16 @@ bool QSGVideoItemSurface::present(const QVideoFrame &frame) return true; } +void QSGVideoItemSurface::scheduleOpenGLContextUpdate() +{ + //This method is called from render thread + QMetaObject::invokeMethod(this, "updateOpenGLContext"); +} + +void QSGVideoItemSurface::updateOpenGLContext() +{ + //Set a dynamic property to access the OpenGL context in Qt Quick render thread. + this->setProperty("GLContext", QVariant::fromValue<QObject*>(m_backend->glContext())); +} + QT_END_NAMESPACE |