QDeadlineTimer: use std::chrono::ceil() in setRemainingTime()
In case the time is of less than 1 ns, we want to make sure it remains non-zero. Change-Id: I3e3bfef633af4130a03afffd175d9c4903271f80 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
This commit is contained in:
parent
285f92bd54
commit
d848e6d87d
@ -109,10 +109,11 @@ public:
|
||||
template <class Rep, class Period>
|
||||
void setRemainingTime(std::chrono::duration<Rep, Period> remaining, Qt::TimerType type_ = Qt::CoarseTimer)
|
||||
{
|
||||
using namespace std::chrono;
|
||||
if (remaining == remaining.max())
|
||||
*this = QDeadlineTimer(Forever, type_);
|
||||
else
|
||||
setPreciseRemainingTime(0, std::chrono::nanoseconds(remaining).count(), type_);
|
||||
setPreciseRemainingTime(0, ceil<nanoseconds>(remaining).count(), type_);
|
||||
}
|
||||
|
||||
std::chrono::nanoseconds remainingTimeAsDuration() const noexcept
|
||||
|
Loading…
Reference in New Issue
Block a user