mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-28 04:31:06 +00:00
qmlglsink: fix crash when created/destroyed in quick succession
The crash is caused by a race condition where the render thread calls a method on the QtGLVideoItem instance that was previously destroyed by the main thread. Also, less frequently, QtGLVideoItem::onSceneGraphInitialized is called when QQuickItem::window is null, also causing a crash. Fixes #798 Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/777>
This commit is contained in:
parent
d885cc0f1a
commit
27ecd2c30d
1 changed files with 7 additions and 2 deletions
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include <QtCore/QRunnable>
|
||||
#include <QtCore/QMutexLocker>
|
||||
#include <QtCore/QPointer>
|
||||
#include <QtGui/QGuiApplication>
|
||||
#include <QtQuick/QQuickWindow>
|
||||
#include <QtQuick/QSGSimpleTextureNode>
|
||||
|
@ -87,7 +88,7 @@ public:
|
|||
void run();
|
||||
|
||||
private:
|
||||
QtGLVideoItem *item_;
|
||||
QPointer<QtGLVideoItem> item_;
|
||||
};
|
||||
|
||||
InitializeSceneGraph::InitializeSceneGraph(QtGLVideoItem *item) :
|
||||
|
@ -97,7 +98,8 @@ InitializeSceneGraph::InitializeSceneGraph(QtGLVideoItem *item) :
|
|||
|
||||
void InitializeSceneGraph::run()
|
||||
{
|
||||
item_->onSceneGraphInitialized();
|
||||
if(item_)
|
||||
item_->onSceneGraphInitialized();
|
||||
}
|
||||
|
||||
QtGLVideoItem::QtGLVideoItem()
|
||||
|
@ -285,6 +287,9 @@ QtGLVideoItemInterface::setBuffer (GstBuffer * buffer)
|
|||
void
|
||||
QtGLVideoItem::onSceneGraphInitialized ()
|
||||
{
|
||||
if (this->window() == NULL)
|
||||
return;
|
||||
|
||||
GST_DEBUG ("%p scene graph initialization with Qt GL context %p", this,
|
||||
this->window()->openglContext ());
|
||||
|
||||
|
|
Loading…
Reference in a new issue