summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPiotr Srebrny <piotr.srebrny@qt.io>2021-12-16 18:33:46 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-12-17 11:48:00 +0000
commit0d11ed2f1bb39a0ffdf55beeabbbdc5bdd5ac357 (patch)
tree8852a41f79536b0a72c117bc78031e40e9f3c2ac
parent0f4153187403da5470427d1703e2e4c8e33012fd (diff)
Don't leak GStramer bus object, make virtual destructor in base class
This patch removes an unnecessary reference increment on the bus object in QGstPipelinePrivate as the bus is owned by QGstPipelinePrivate. Add virtual destructor in the QGstObject as QGstPipeline inherits from it. Provide correct handling of self-assignment operation for QGstPipeline and QGstObject. Change-Id: I41a333be8c2d8596aa1d11a9e1c11f4410ed6283 Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 77096edebd7dda161db42b92a5b3bc41f9c69740) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/multimedia/platform/gstreamer/common/qgst_p.h4
-rw-r--r--src/multimedia/platform/gstreamer/common/qgstpipeline.cpp4
-rw-r--r--src/multimedia/platform/gstreamer/common/qgstpipeline_p.h2
3 files changed, 6 insertions, 4 deletions
diff --git a/src/multimedia/platform/gstreamer/common/qgst_p.h b/src/multimedia/platform/gstreamer/common/qgst_p.h
index 7e902c352..5b644bfda 100644
--- a/src/multimedia/platform/gstreamer/common/qgst_p.h
+++ b/src/multimedia/platform/gstreamer/common/qgst_p.h
@@ -298,6 +298,8 @@ public:
}
QGstObject &operator=(const QGstObject &other)
{
+ if (this == &other)
+ return *this;
if (other.m_object)
gst_object_ref(other.m_object);
if (m_object)
@@ -305,7 +307,7 @@ public:
m_object = other.m_object;
return *this;
}
- ~QGstObject() {
+ virtual ~QGstObject() {
if (m_object)
gst_object_unref(m_object);
}
diff --git a/src/multimedia/platform/gstreamer/common/qgstpipeline.cpp b/src/multimedia/platform/gstreamer/common/qgstpipeline.cpp
index 29fb0a552..1f20fe4ec 100644
--- a/src/multimedia/platform/gstreamer/common/qgstpipeline.cpp
+++ b/src/multimedia/platform/gstreamer/common/qgstpipeline.cpp
@@ -140,8 +140,6 @@ QGstPipelinePrivate::QGstPipelinePrivate(GstBus* bus, QObject* parent)
: QObject(parent),
m_bus(bus)
{
- gst_object_ref(GST_OBJECT(bus));
-
// glib event loop can be disabled either by env variable or QT_NO_GLIB define, so check the dispacher
QAbstractEventDispatcher *dispatcher = QCoreApplication::eventDispatcher();
const bool hasGlib = dispatcher && dispatcher->inherits("QEventDispatcherGlib");
@@ -207,6 +205,8 @@ QGstPipeline::QGstPipeline(const QGstPipeline &o)
QGstPipeline &QGstPipeline::operator=(const QGstPipeline &o)
{
+ if (this == &o)
+ return *this;
if (o.d)
o.d->ref();
if (d)
diff --git a/src/multimedia/platform/gstreamer/common/qgstpipeline_p.h b/src/multimedia/platform/gstreamer/common/qgstpipeline_p.h
index 133fb167b..90d457ca2 100644
--- a/src/multimedia/platform/gstreamer/common/qgstpipeline_p.h
+++ b/src/multimedia/platform/gstreamer/common/qgstpipeline_p.h
@@ -84,7 +84,7 @@ public:
QGstPipeline &operator=(const QGstPipeline &o);
QGstPipeline(const char *name);
QGstPipeline(GstPipeline *p);
- ~QGstPipeline();
+ ~QGstPipeline() override;
// This is needed to help us avoid sending QVideoFrames or audio buffers to the
// application while we're prerolling the pipeline.