summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qeventdispatcher_glib.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2024-02-18 19:24:02 -0800
committerThiago Macieira <thiago.macieira@intel.com>2024-03-13 17:29:13 -0800
commit9dc2935462ef42a5172b19b2bd4a8b938cf40bee (patch)
treef5d243755062d87b1cb417feb0e822c5d17eaa52 /src/corelib/kernel/qeventdispatcher_glib.cpp
parent1ca89b65d85c5df971fac7c1f9d5678e0e0cf45b (diff)
QTimerInfo: store nanoseconds instead of milliseconds
No change in behavior, other than the ability for the precise timers to be even more precise. There's a reduction in the stored interval range from 292 million years to 292 years, but there's no change in behavior because the timeout is stored as a steady_clock::time_point, which is nanoseconds with libstdc++ and libc++. Now, if there's an overflow, it'll happen on the call to registerTimer() instead of inside the calculation of the wake-up. Change-Id: I83dda2d36c904517b3c0fffd17b3d1f2d9505c1c Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Diffstat (limited to 'src/corelib/kernel/qeventdispatcher_glib.cpp')
-rw-r--r--src/corelib/kernel/qeventdispatcher_glib.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/corelib/kernel/qeventdispatcher_glib.cpp b/src/corelib/kernel/qeventdispatcher_glib.cpp
index 4be4fea98a..ba3a1ea988 100644
--- a/src/corelib/kernel/qeventdispatcher_glib.cpp
+++ b/src/corelib/kernel/qeventdispatcher_glib.cpp
@@ -14,6 +14,7 @@
#include <glib.h>
+using namespace std::chrono;
using namespace std::chrono_literals;
QT_BEGIN_NAMESPACE
@@ -102,8 +103,8 @@ static gboolean timerSourcePrepareHelper(GTimerSource *src, gint *timeout)
return true;
}
- auto msecs = src->timerList.timerWait().value_or(-1ms);
- *timeout = qt_saturate<gint>(msecs.count());
+ auto remaining = src->timerList.timerWait().value_or(-1ms);
+ *timeout = qt_saturate<gint>(ceil<milliseconds>(remaining).count());
return (*timeout == 0);
}