From patchwork Sun Jun 30 16:25:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 1529 Return-Path: Received: from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net [195.74.38.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6309160BC7 for ; Sun, 30 Jun 2019 18:25:31 +0200 (CEST) X-Halon-ID: a0ff70a1-9b53-11e9-8ab4-005056917a89 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (unknown [145.14.112.32]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id a0ff70a1-9b53-11e9-8ab4-005056917a89; Sun, 30 Jun 2019 18:25:10 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Sun, 30 Jun 2019 18:25:12 +0200 Message-Id: <20190630162514.20522-2-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190630162514.20522-1-niklas.soderlund@ragnatech.se> References: <20190630162514.20522-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/3] libcamera: timer: Stop timer when it is deleted X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Jun 2019 16:25:31 -0000 If a timer is running while it's deleted it is still register with the event dispatcher. This causes a segmentation fault when the timer time-out and its signal is emitted. Fix this my stopping the timer when it's deleted. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- include/libcamera/timer.h | 1 + src/libcamera/timer.cpp | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/include/libcamera/timer.h b/include/libcamera/timer.h index 97dcc01f493dc70d..f082339b1fed9de7 100644 --- a/include/libcamera/timer.h +++ b/include/libcamera/timer.h @@ -17,6 +17,7 @@ class Timer { public: Timer(); + ~Timer(); void start(unsigned int msec); void stop(); diff --git a/src/libcamera/timer.cpp b/src/libcamera/timer.cpp index 1cce45085c61be2f..0dcb4e767be30b32 100644 --- a/src/libcamera/timer.cpp +++ b/src/libcamera/timer.cpp @@ -43,6 +43,11 @@ Timer::Timer() { } +Timer::~Timer() +{ + stop(); +} + /** * \brief Start or restart the timer with a timeout of \a msec * \param[in] msec The timer duration in milliseconds