[{"id":2707,"web_url":"https://patchwork.libcamera.org/comment/2707/","msgid":"<20190927205713.GH4862@pendragon.ideasonboard.com>","date":"2019-09-27T20:57:13","subject":"Re: [libcamera-devel] [PATCH v2 2/2] qcam: Fix timers not emitting\n\ttimeout signal","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Niklas,\n\nThank you for the patch.\n\nOn Fri, Sep 27, 2019 at 10:16:41PM +0200, Niklas Söderlund wrote:\n> The timer signal was never emitted in QtEventDispatcher::timerEvent(),\n> this results in timers not working as designed running under the Qt\n> event loop. Fix this by emitting the signal on timeout and stopping the\n> timer. By stopping the timer unregisterTimer() is called which handles\n> the cleanup.\n\nThat's actually two changes in one patch. Did I hear you requesting\nbefore that patches should be split with one change per patch ? ;-)\n\nThe move to timer->stop() isn't just cosmetics, it ensures that the\nTimer::deadline_ field gets reset to 0, so it fixes potential bugs. You\nshould probably mention this in the commit message.\n\n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  src/qcam/qt_event_dispatcher.cpp | 7 ++++---\n>  1 file changed, 4 insertions(+), 3 deletions(-)\n> \n> diff --git a/src/qcam/qt_event_dispatcher.cpp b/src/qcam/qt_event_dispatcher.cpp\n> index 98d2472c37856642..d7d1fed290851e6e 100644\n> --- a/src/qcam/qt_event_dispatcher.cpp\n> +++ b/src/qcam/qt_event_dispatcher.cpp\n> @@ -131,9 +131,10 @@ void QtEventDispatcher::unregisterTimer(Timer *timer)\n>  void QtEventDispatcher::timerEvent(QTimerEvent *event)\n>  {\n>  \tauto it = timers_.find(event->timerId());\n> -\ttimerIds_.erase(it->second);\n> -\tkillTimer(it->first);\n> -\ttimers_.erase(it);\n> +\tTimer *timer = it->second;\n> +\n> +\ttimer->stop();\n> +\ttimer->timeout.emit(timer);\n>  }\n>  \n>  void QtEventDispatcher::processEvents()","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3B36560BF1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 27 Sep 2019 22:57:26 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi\n\t[IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7989A741;\n\tFri, 27 Sep 2019 22:57:25 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1569617845;\n\tbh=vNnR8UTnTYCqbbHQhJfCPz/RSQDnrYH9WgMuRO/jbwc=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=vCNZ8IcKo0Xh5sFxH+0ENpcQJAQG2ZG8NASEbsm+tk+weHNmJ/x3LT3azll13efO4\n\t0+6XB9ym4R9woyc/r+pZdJkVKk8wfatQKjrk2m7h5H1uw7avN76Fc3MQWJ3a1WM9sh\n\t1ZFfsczM6nWi5tvD9p/saO2ZZRwScJn2uzok8OCc=","Date":"Fri, 27 Sep 2019 23:57:13 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190927205713.GH4862@pendragon.ideasonboard.com>","References":"<20190927201641.813877-1-niklas.soderlund@ragnatech.se>\n\t<20190927201641.813877-3-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20190927201641.813877-3-niklas.soderlund@ragnatech.se>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v2 2/2] qcam: Fix timers not emitting\n\ttimeout signal","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Fri, 27 Sep 2019 20:57:26 -0000"}}]