diff options
author | Bastien Reboulet <bastien.reboulet@gmail.com> | 2020-10-16 16:05:45 -0700 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.com> | 2020-10-22 19:21:53 +0100 |
commit | 2a3c52b9b7dc966251bda717e2609faba1b62722 (patch) | |
tree | 6c4c515bab87f4d51ffe34ad3534bee60636dd79 | |
parent | d03110437e3b596560cf0beaf477ebd2104d54fd (diff) |
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/781>
-rw-r--r-- | ext/qt/qtitem.cc | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/ext/qt/qtitem.cc b/ext/qt/qtitem.cc index 49dafc87e..7659800b6 100644 --- a/ext/qt/qtitem.cc +++ b/ext/qt/qtitem.cc @@ -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 ()); |