From 6348649bc6220d4aaa36e92b4876c43ab1672cdb Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Sun, 12 Nov 2023 21:57:59 +0100 Subject: [PATCH] GstEnginePipeline: Run QTimer::singleShot in main thread Partial fix for #1302 --- src/core/metatypes.cpp | 1 + src/engine/gstenginepipeline.cpp | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/core/metatypes.cpp b/src/core/metatypes.cpp index 8b9c4f5a9..d071929d1 100644 --- a/src/core/metatypes.cpp +++ b/src/core/metatypes.cpp @@ -110,6 +110,7 @@ void RegisterMetaTypes() { #ifdef HAVE_GSTREAMER qRegisterMetaType("GstBuffer*"); qRegisterMetaType("GstElement*"); + qRegisterMetaType("GstState"); qRegisterMetaType("GstEnginePipeline*"); #endif qRegisterMetaType("CollectionDirectory"); diff --git a/src/engine/gstenginepipeline.cpp b/src/engine/gstenginepipeline.cpp index 2e36734df..94e81e731 100644 --- a/src/engine/gstenginepipeline.cpp +++ b/src/engine/gstenginepipeline.cpp @@ -1552,7 +1552,9 @@ QFuture GstEnginePipeline::SetState(const GstState state) void GstEnginePipeline::SetStateDelayed(const GstState state) { - QTimer::singleShot(300, this, [this, state]() { SetState(state); }); + QMetaObject::invokeMethod(this, [this, state]() { + QTimer::singleShot(300, this, [this, state]() { SetState(state); }); + }, Qt::QueuedConnection); } @@ -1591,7 +1593,9 @@ void GstEnginePipeline::SeekQueued(const qint64 nanosec) { void GstEnginePipeline::SeekDelayed(const qint64 nanosec) { - QTimer::singleShot(100, this, [this, nanosec]() { SeekQueued(nanosec); }); + QMetaObject::invokeMethod(this, [this, nanosec]() { + QTimer::singleShot(100, this, [this, nanosec]() { Seek(nanosec); }); + }, Qt::QueuedConnection); }