[{"id":2738,"web_url":"https://patchwork.libcamera.org/comment/2738/","msgid":"<20191001010645.GB4739@pendragon.ideasonboard.com>","date":"2019-10-01T01:06:45","subject":"Re: [libcamera-devel] [PATCH v3 2/3] qcam: Stop timer on timeout","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 Mon, Sep 30, 2019 at 11:59:05PM +0200, Niklas Söderlund wrote:\n> Stopping the timer will reset the Timer::deadline_ field to 0 fixing\n> potential bugs and call QtEventDispatcher::unregisterTimer() which will\n> take care of the cleanup.\n> \n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> ---\n>  src/qcam/qt_event_dispatcher.cpp | 6 +++---\n>  1 file changed, 3 insertions(+), 3 deletions(-)\n> \n> diff --git a/src/qcam/qt_event_dispatcher.cpp b/src/qcam/qt_event_dispatcher.cpp\n> index 98d2472c37856642..43588ef081a3f633 100644\n> --- a/src/qcam/qt_event_dispatcher.cpp\n> +++ b/src/qcam/qt_event_dispatcher.cpp\n> @@ -131,9 +131,9 @@ 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\nCould this be simplified to\n\n\tTimer *timer = timers_[event->timerId()];\n\ttimer->stop();\n\n? If you think there's a risk that timerEvent would be called with a\nnon-registered timer (bug in Qt or in qcam ?), then you can keep using\nfind(), but you should then check for it == timers_.end(). I'll let you\ncheck if this would be overkill or useful.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +\n> +\ttimer->stop();\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 61B2661654\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  1 Oct 2019 03:06:58 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(modemcable151.96-160-184.mc.videotron.ca [184.160.96.151])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7DA682BB;\n\tTue,  1 Oct 2019 03:06:57 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1569892018;\n\tbh=8391jfJyTxIDLv5g+FN5N2zDQJAPGz/BpJSE+8vN23k=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=wJ2Cf6EkfbM20/pqUBQ06hnDRV8oAFsxi2w6kwstPhmeE9JdUFRuZtZ+lzjRULq8K\n\ttY4UbW96xgddAtd8FP5dUJ+tFITEqRbRb8qZnaYMrxe+jllbqZI3R4xISvNd/g+k7J\n\twA1PKom2OZZ6VV0Q5C0+LQlHiMCSGVYC2M4xNI8A=","Date":"Tue, 1 Oct 2019 04:06:45 +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":"<20191001010645.GB4739@pendragon.ideasonboard.com>","References":"<20190930215906.1058301-1-niklas.soderlund@ragnatech.se>\n\t<20190930215906.1058301-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":"<20190930215906.1058301-3-niklas.soderlund@ragnatech.se>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v3 2/3] qcam: Stop timer on timeout","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":"Tue, 01 Oct 2019 01:06:58 -0000"}},{"id":2740,"web_url":"https://patchwork.libcamera.org/comment/2740/","msgid":"<20191001133616.GD18341@bigcity.dyn.berto.se>","date":"2019-10-01T13:36:16","subject":"Re: [libcamera-devel] [PATCH v3 2/3] qcam: Stop timer on timeout","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Laurent,\n\nThanks for your feedback.\n\nOn 2019-10-01 04:06:45 +0300, Laurent Pinchart wrote:\n> Hi Niklas,\n> \n> Thank you for the patch.\n> \n> On Mon, Sep 30, 2019 at 11:59:05PM +0200, Niklas Söderlund wrote:\n> > Stopping the timer will reset the Timer::deadline_ field to 0 fixing\n> > potential bugs and call QtEventDispatcher::unregisterTimer() which will\n> > take care of the cleanup.\n> > \n> > Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> > ---\n> >  src/qcam/qt_event_dispatcher.cpp | 6 +++---\n> >  1 file changed, 3 insertions(+), 3 deletions(-)\n> > \n> > diff --git a/src/qcam/qt_event_dispatcher.cpp b/src/qcam/qt_event_dispatcher.cpp\n> > index 98d2472c37856642..43588ef081a3f633 100644\n> > --- a/src/qcam/qt_event_dispatcher.cpp\n> > +++ b/src/qcam/qt_event_dispatcher.cpp\n> > @@ -131,9 +131,9 @@ 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> Could this be simplified to\n> \n> \tTimer *timer = timers_[event->timerId()];\n> \ttimer->stop();\n> \n> ? If you think there's a risk that timerEvent would be called with a\n> non-registered timer (bug in Qt or in qcam ?), then you can keep using\n> find(), but you should then check for it == timers_.end(). I'll let you\n> check if this would be overkill or useful.\n\nI like this change and I have taken it in together with your tag,\nthanks!\n\n> \n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> \n> > +\n> > +\ttimer->stop();\n> >  }\n> >  \n> >  void QtEventDispatcher::processEvents()\n> \n> -- \n> Regards,\n> \n> Laurent Pinchart","headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from mail-lj1-x242.google.com (mail-lj1-x242.google.com\n\t[IPv6:2a00:1450:4864:20::242])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AA13C60BC6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  1 Oct 2019 15:36:18 +0200 (CEST)","by mail-lj1-x242.google.com with SMTP id v24so13409081ljj.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 01 Oct 2019 06:36:18 -0700 (PDT)","from localhost (h-93-159.A463.priv.bahnhof.se. [46.59.93.159])\n\tby smtp.gmail.com with ESMTPSA id\n\t202sm4039237ljf.75.2019.10.01.06.36.16\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 01 Oct 2019 06:36:16 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to\n\t:user-agent; bh=LBs51uKQz4NBQM/j7Rkq1esi9DHKIztNwjVYQcc2Z2s=;\n\tb=m25x8rzIELEa7Py91oyrLr5y5rmHLO1BCBcizs+iTUXclHSRCSOxHgQWdJAWYlrICV\n\tFJjcTwAiYyIteijwIRJZKAnaf34yhn8QePB8RulPb5QYwVtsNJGfUgVc1HleR1fdY7G1\n\tjCf3FHSRBy8rRdPVUqO2dSrAFS3CwGXR3+eGgIM4agWaM1udGHzp0qvYWhVeRnOV5T0t\n\tuy6hyVE0hXmAo3hFaPa47MwAFcA6HQYgXU0f3CCuxoiCAVZinf/4xKSBIsBl50z0bbKz\n\toXYHE6j/5Y0mp5gyhWuYgTorv0LuBjCRFVaLH4OgoAGrMBtvsmXnX/l/G8HUhwqByIRv\n\tXnCA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to:user-agent;\n\tbh=LBs51uKQz4NBQM/j7Rkq1esi9DHKIztNwjVYQcc2Z2s=;\n\tb=uXGDa6yayS5Oong/67NXRXiUUj1404MjIYL1HCc1DO6AJlq9+W6uj42X1u/DTU4ZLf\n\t95B8QthwmJGpDJuLuRjI5rtbdT8aiciMyV/wSvBV3zwQ9gUxUBbobupsDP1EI/5CSxco\n\tg6tWmTYIKnfm+q8GR+53mMkljn4E8ZL/MnVyGg2mGOU2cj7AMhFhJhU9k0eH4H6RF+KM\n\t/WYpXrGaQzvzBk2xX+AcUP6CMsHnJb1u6PQLZ7zoEm/+YK/gk29lgiEeaMHcPsrwt4OZ\n\tByrpNDIWbZ4SN9RzzCkjwU07Q8tvI3BXeQ+Ec3xUkfluTL+AAbH4iy/GaFW1gPxNDHJW\n\toDJg==","X-Gm-Message-State":"APjAAAWCmg1ukVx34huLccWBKkw2q2zvHJaNEedXOSXqAz7EkB/mW3c/\n\tWqzck14H96Kt/MjNWLmlfQaJW8R6F2g=","X-Google-Smtp-Source":"APXvYqyqiZ5pHNws2poMxB0egvEV3CVIoTWb1Rkqn3ueccEWUKmkCwIl0pfxUw+1I0SUav1T1Nrynw==","X-Received":"by 2002:a2e:9d16:: with SMTP id\n\tt22mr1203648lji.207.1569936977794; \n\tTue, 01 Oct 2019 06:36:17 -0700 (PDT)","Date":"Tue, 1 Oct 2019 15:36:16 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20191001133616.GD18341@bigcity.dyn.berto.se>","References":"<20190930215906.1058301-1-niklas.soderlund@ragnatech.se>\n\t<20190930215906.1058301-3-niklas.soderlund@ragnatech.se>\n\t<20191001010645.GB4739@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20191001010645.GB4739@pendragon.ideasonboard.com>","User-Agent":"Mutt/1.12.1 (2019-06-15)","Subject":"Re: [libcamera-devel] [PATCH v3 2/3] qcam: Stop timer on timeout","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":"Tue, 01 Oct 2019 13:36:18 -0000"}}]