diff options
author | VaL Doroshchuk <valentyn.doroshchuk@qt.io> | 2017-10-27 14:20:51 +0200 |
---|---|---|
committer | VaL Doroshchuk <valentyn.doroshchuk@qt.io> | 2017-11-08 08:33:15 +0000 |
commit | b42659eb8baa384e329e6af6afea89bb4005fb46 (patch) | |
tree | 99b0bede63079985429a6c43bef153c470924bfa /src/plugins/gstreamer/camerabin/camerabinsession.cpp | |
parent | c3c6b7d0987b90e4a987ee84b2f31adf06568a0d (diff) | |
download | qtmultimedia-b42659eb8baa384e329e6af6afea89bb4005fb46.tar.gz |
Gstreamer: Fix memory leak in CameraBinSession
Created GstElement objects m_cameraSrc and m_videoSrc should be unrefed.
Task-number: QTBUG-53204
Change-Id: Ibbfd37d928fe87ea899549da7c12fa2386e214cc
Reviewed-by: Christian Stromme <christian.stromme@qt.io>
Diffstat (limited to 'src/plugins/gstreamer/camerabin/camerabinsession.cpp')
-rw-r--r-- | src/plugins/gstreamer/camerabin/camerabinsession.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/plugins/gstreamer/camerabin/camerabinsession.cpp b/src/plugins/gstreamer/camerabin/camerabinsession.cpp index ab0bea24a..4941c6ef6 100644 --- a/src/plugins/gstreamer/camerabin/camerabinsession.cpp +++ b/src/plugins/gstreamer/camerabin/camerabinsession.cpp @@ -212,6 +212,12 @@ CameraBinSession::~CameraBinSession() if (m_sourceFactory) gst_object_unref(GST_OBJECT(m_sourceFactory)); + + if (m_cameraSrc) + gst_object_unref(GST_OBJECT(m_cameraSrc)); + + if (m_videoSrc) + gst_object_unref(GST_OBJECT(m_videoSrc)); } #if QT_CONFIG(gstreamer_photography) @@ -538,11 +544,12 @@ GstElement *CameraBinSession::buildCameraSource() } } - if (m_cameraSrc != camSrc) + if (m_cameraSrc != camSrc) { g_object_set(G_OBJECT(m_camerabin), CAMERA_SOURCE_PROPERTY, m_cameraSrc, NULL); - - if (camSrc) - gst_object_unref(GST_OBJECT(camSrc)); + // Unref only if camSrc is not m_cameraSrc to prevent double unrefing. + if (camSrc) + gst_object_unref(GST_OBJECT(camSrc)); + } return m_cameraSrc; } |