[libcamera-devel] qcam: Support Qt versions earlier than 5.9

Message ID 20191016232018.30239-1-laurent.pinchart@ideasonboard.com
State Accepted
Commit 6b6c02e2236c22136c7b0d8d7141dd19dd0d6386
Headers show
Series
  • [libcamera-devel] qcam: Support Qt versions earlier than 5.9
Related show

Commit Message

Laurent Pinchart Oct. 16, 2019, 11:20 p.m. UTC
The QtEventDispatcher timers implementation depends on Qt 5.9 or newer
due to the use of QObject::startTimer(std::chrono::milliseconds).
Support earlier Qt versions by using the QObject::startTimer(int)
version instead.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/qcam/qt_event_dispatcher.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Niklas Söderlund Oct. 16, 2019, 11:23 p.m. UTC | #1
Hi Laurent,

Thanks for your patch.

On 2019-10-17 02:20:18 +0300, Laurent Pinchart wrote:
> The QtEventDispatcher timers implementation depends on Qt 5.9 or newer
> due to the use of QObject::startTimer(std::chrono::milliseconds).
> Support earlier Qt versions by using the QObject::startTimer(int)
> version instead.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

This fixes the problem I ran into on gcc 6.3.0.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

> ---
>  src/qcam/qt_event_dispatcher.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/qcam/qt_event_dispatcher.cpp b/src/qcam/qt_event_dispatcher.cpp
> index 9e989bef7d53..2780c9123ac3 100644
> --- a/src/qcam/qt_event_dispatcher.cpp
> +++ b/src/qcam/qt_event_dispatcher.cpp
> @@ -117,7 +117,7 @@ void QtEventDispatcher::registerTimer(Timer *timer)
>  	std::chrono::steady_clock::duration duration = timer->deadline() - now;
>  	std::chrono::milliseconds msec =
>  		std::chrono::duration_cast<std::chrono::milliseconds>(duration);
> -	int timerId = startTimer(msec);
> +	int timerId = startTimer(msec.count());
>  	timers_[timerId] = timer;
>  	timerIds_[timer] = timerId;
>  }
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/src/qcam/qt_event_dispatcher.cpp b/src/qcam/qt_event_dispatcher.cpp
index 9e989bef7d53..2780c9123ac3 100644
--- a/src/qcam/qt_event_dispatcher.cpp
+++ b/src/qcam/qt_event_dispatcher.cpp
@@ -117,7 +117,7 @@  void QtEventDispatcher::registerTimer(Timer *timer)
 	std::chrono::steady_clock::duration duration = timer->deadline() - now;
 	std::chrono::milliseconds msec =
 		std::chrono::duration_cast<std::chrono::milliseconds>(duration);
-	int timerId = startTimer(msec);
+	int timerId = startTimer(msec.count());
 	timers_[timerId] = timer;
 	timerIds_[timer] = timerId;
 }