[libcamera-devel,v3,1/3] qcam: Fix unregister of not registered timer

Message ID 20190930215906.1058301-2-niklas.soderlund@ragnatech.se
State Accepted
Headers show
Series
  • qcam: Fix issues in the Qt event dispatcher
Related show

Commit Message

Niklas Söderlund Sept. 30, 2019, 9:59 p.m. UTC
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@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/qcam/qt_event_dispatcher.cpp | 3 +++
 1 file changed, 3 insertions(+)

Patch

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);