[libcamera-devel] [PATCH 2/2] qcam: Fix timers not emitting timeout signal

Niklas Söderlund niklas.soderlund at ragnatech.se
Fri Sep 27 04:30:23 CEST 2019


The timer signal was never emitted in QtEventDispatcher::timerEvent(),
this results in timers not working as designed running under the Qt
event loop. Fix this by emitting the signal on timeout.

Signed-off-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
---
 src/qcam/qt_event_dispatcher.cpp | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/qcam/qt_event_dispatcher.cpp b/src/qcam/qt_event_dispatcher.cpp
index 6b332f6265d01fe0..fcde374c9936d1f9 100644
--- a/src/qcam/qt_event_dispatcher.cpp
+++ b/src/qcam/qt_event_dispatcher.cpp
@@ -132,9 +132,19 @@ void QtEventDispatcher::unregisterTimer(Timer *timer)
 void QtEventDispatcher::timerEvent(QTimerEvent *event)
 {
 	auto it = timers_.find(event->timerId());
-	timerIds_.erase(it->second);
+
+	if (it == timers_.end()) {
+		std::cout << "Can't find timer for event" << std::endl;
+		return;
+	}
+
+	Timer *timer = it->second;
+
+	timerIds_.erase(timer);
 	killTimer(it->first);
 	timers_.erase(it);
+
+	timer->timeout.emit(timer);
 }
 
 void QtEventDispatcher::processEvents()
-- 
2.23.0



More information about the libcamera-devel mailing list