From patchwork Mon Jul 27 12:32:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 9015 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 32476BD86F for ; Mon, 27 Jul 2020 12:33:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A63BB613AA; Mon, 27 Jul 2020 14:33:03 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=uajain.com header.i=@uajain.com header.b="gl+Kmvn9"; dkim-atps=neutral Received: from o1.f.az.sendgrid.net (o1.f.az.sendgrid.net [208.117.55.132]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 524B260939 for ; Mon, 27 Jul 2020 14:33:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uajain.com; h=from:subject:mime-version:to:cc:content-transfer-encoding: content-type; s=s1; bh=tLpeChWmqu96NUTJsxWK+mIuZSWujYQgBz3DWOCpQgE=; b=gl+Kmvn9YtIKduW/p7NGaJoJv6K2nVVLOrKeYEwXWv7Q/6dA0dYqvccblwIEnPVBS6oZ GhAknJzf8bqMXlbz7WaP05jZd6awBkx3/KTLRaKyEBo8ZQUKCDvsaKgCndBDsV4CcyLg+q O1K3c4YphcThce/4KrDedRUVkBIj7PF4o= Received: by filterdrecv-p3las1-7754f7d4cc-l8z88 with SMTP id filterdrecv-p3las1-7754f7d4cc-l8z88-20-5F1EC97A-88 2020-07-27 12:32:58.965596672 +0000 UTC m=+2744361.226590960 Received: from mail.uajain.com (unknown) by ismtpd0001p1maa1.sendgrid.net (SG) with ESMTP id kTCM2PgzR8a9L6WB-R67Yg for ; Mon, 27 Jul 2020 12:32:58.285 +0000 (UTC) From: Umang Jain Date: Mon, 27 Jul 2020 12:32:59 +0000 (UTC) Message-Id: <20200727123247.20412-1-email@uajain.com> Mime-Version: 1.0 X-SG-EID: 1Q40EQ7YGir8a9gjSIAdTjhngY657NMk9ckeo4dbHZDiOpywc/L3L9rFqlwE4KPcp6CL6ozs3IeZvk96OtB41JK3zJzypOxB6I5DMBQySpYkFUGxUA6Ym/uFJj5EKuxoeLM5CkrZB50eopQxSZyCy/gaJj2p4Yr5qSvyl+OgiZ0ApUC86zLcKIKl+YsFJjpJdQAkFh+h7BvryEeAul7teLriGw3uk+OYOgdjt3R2n/PpdX5ST8fv21jxMjvAVu9GGUb1+kzK1x/QEDH0Qa1BIg== To: libcamera-devel@lists.libcamera.org Subject: [libcamera-devel] [PATCH] qcam: Fix camera reference leak on hot-unplug X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" If the currently streaming camera is hot-unplugged, a camera reference was still held by MainWindow::camera_, preventing it to be destructed, until qcam window is closed. Plug the leak in the hot-unplug handler itself. Signed-off-by: Umang Jain Reviewed-by: Laurent Pinchart --- src/qcam/main_window.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index 7bc1360..c8298ec 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -587,6 +587,8 @@ void MainWindow::processHotplug(HotplugEvent *e) /* Check if the currently-streaming camera is removed. */ if (camera == camera_.get()) { toggleCapture(false); + camera_->release(); + camera_.reset(); cameraCombo_->setCurrentIndex(0); }