From 466a4f29c20b6d797af9d67029a7329b2124b276 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 29 Nov 2021 15:52:25 +0100 Subject: Fix a memory leak in the camerabinsession Properly unref the video and camera source objects when changing the input device. Fixes: QTBUG-93762 Change-Id: Ibaf08978b6915faa668ef0ab54b3bc0903daafad Reviewed-by: Piotr Srebrny Reviewed-by: Lars Knoll --- src/plugins/gstreamer/camerabin/camerabinsession.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/plugins/gstreamer/camerabin/camerabinsession.cpp b/src/plugins/gstreamer/camerabin/camerabinsession.cpp index 26080f979..dd81240f0 100644 --- a/src/plugins/gstreamer/camerabin/camerabinsession.cpp +++ b/src/plugins/gstreamer/camerabin/camerabinsession.cpp @@ -479,6 +479,15 @@ GstElement *CameraBinSession::buildCameraSource() m_inputDeviceHasChanged = false; m_usingWrapperCameraBinSrc = false; + if (m_videoSrc) { + gst_object_unref(GST_OBJECT(m_videoSrc)); + m_videoSrc = 0; + } + if (m_cameraSrc) { + gst_object_unref(GST_OBJECT(m_cameraSrc)); + m_cameraSrc = 0; + } + GstElement *camSrc = 0; g_object_get(G_OBJECT(m_camerabin), CAMERA_SOURCE_PROPERTY, &camSrc, NULL); -- cgit v1.2.1