[libcamera-devel] [PATCH v2 1/2] qcam: Fix unregister of not registered timer

Niklas Söderlund niklas.soderlund at ragnatech.se
Fri Sep 27 22:16:40 CEST 2019


If an unregistered timer is given to QtEventDispatcher::unregisterTimer()
an error is printed and Qt gets confused and locks up. Fix this by
following the libcamera documentation that passing a unregistered timer
is a no-op.

Signed-off-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
 src/qcam/qt_event_dispatcher.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/qcam/qt_event_dispatcher.cpp b/src/qcam/qt_event_dispatcher.cpp
index 5ba451bf88cef6e8..98d2472c37856642 100644
--- a/src/qcam/qt_event_dispatcher.cpp
+++ b/src/qcam/qt_event_dispatcher.cpp
@@ -120,6 +120,9 @@ void QtEventDispatcher::registerTimer(Timer *timer)
 void QtEventDispatcher::unregisterTimer(Timer *timer)
 {
 	auto it = timerIds_.find(timer);
+	if (it == timerIds_.end())
+		return;
+
 	timers_.erase(it->second);
 	killTimer(it->second);
 	timerIds_.erase(it);
-- 
2.23.0



More information about the libcamera-devel mailing list