summaryrefslogtreecommitdiffstats
path: root/src/corelib/compat
diff options
context:
space:
mode:
authorAhmad Samir <a.samirh78@gmail.com>2024-02-14 22:11:43 +0200
committerAhmad Samir <a.samirh78@gmail.com>2024-02-23 22:07:47 +0200
commitbfc7535a10f7a6e3723f354b41f08a0fe1d18719 (patch)
tree4ee2c19f03cc9952a98a53898b7ed3f2d87204b3 /src/corelib/compat
parentbb058909626410d22ccd74919d69cd747fbc33ad (diff)
QSingleShotTimer: use nanoseconds precision
This is a step towards making QChronoTimer have nanoseconds precision. Not changing QTimer::singleShot() methods to take nanoseconds; QTimer uses milliseconds for the most part, having the static singleShot() methods take nanoseconds would be a bit surprising? [ChangeLog][Core][QObject] Added startTimer() nanoseconds overload and removed the milliseconds overload. This change is backwards compatible. Change-Id: I69e79c8feb6354846c6d3be57dc529af7abd1313 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/corelib/compat')
-rw-r--r--src/corelib/compat/removed_api.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/corelib/compat/removed_api.cpp b/src/corelib/compat/removed_api.cpp
index a2d8d6f63e..b214ca4f36 100644
--- a/src/corelib/compat/removed_api.cpp
+++ b/src/corelib/compat/removed_api.cpp
@@ -4,6 +4,7 @@
#define QT_CORE_BUILD_REMOVED_API
#include "qglobal.h"
+#include "qnumeric.h"
QT_USE_NAMESPACE
@@ -954,6 +955,20 @@ bool QUrlQuery::operator==(const QUrlQuery &other) const
return comparesEqual(*this, other);
}
+#include "qobject.h"
+
+int QObject::startTimer(std::chrono::milliseconds time, Qt::TimerType timerType)
+{
+ using namespace std::chrono;
+ using ratio = std::ratio_divide<std::milli, std::nano>;
+ if (nanoseconds::rep r; qMulOverflow<ratio::num>(time.count(), &r)) {
+ qWarning("QObject::startTimer(std::chrono::milliseconds time ...): "
+ "'time' arg will overflow when converted to nanoseconds.");
+ }
+ return startTimer(nanoseconds{time}, timerType);
+}
+
+
// #include "qotherheader.h"
// // implement removed functions from qotherheader.h
// order sections alphabetically to reduce chances of merge conflicts