summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qnamespace.h
diff options
context:
space:
mode:
authorAhmad Samir <a.samirh78@gmail.com>2023-11-18 21:29:26 +0200
committerAhmad Samir <a.samirh78@gmail.com>2024-03-03 19:56:55 +0200
commit4bc0834bc182335984431c6a1525782efc34368c (patch)
tree87db305cc2d9e0995cf46225b3a5d6dee93c9de3 /src/corelib/global/qnamespace.h
parent577a3dba521f7f69bf6129fcd28184ae288182d9 (diff)
Timers: add Qt::TimerId enum class
Which will be used to represent timer IDs. Thanks to Marc for the idea to use "a strongly typed int". QTimer got a new id() method that returns Qt::TimerId (can't overload timerId()). Various classes in qtbase have a member named timerId(), but a new method is needed anyway in QTimer so id() it is (this is the reason QChronoTimer only has id() and no timerId()). Besides timer.timerId() has an extra "timer". This commit fixes the inconsistency between QObject using `0` timer id to indicate "failed to start", while QTimer::timerId() returned `-1` to indicate "timer is inactive". QTimer::id(), being a new method and all, now returns Qt::TimerId::Invalid, which has value `0`, so that the values match between the two classes. Extend the unittests to ensure QTimer::timerId()'s behavior is preserved. [ChangeLog][Core][QObject] Added Qt::TimerId enum class, that is used to represent timer IDs. Change-Id: I0e8564c1461884106d8a797cc980a669035d480a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/global/qnamespace.h')
-rw-r--r--src/corelib/global/qnamespace.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index a8069c0c3b..33b2a69709 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -1675,6 +1675,10 @@ namespace Qt {
VeryCoarseTimer
};
+ enum class TimerId {
+ Invalid = 0,
+ };
+
enum ScrollPhase {
NoScrollPhase = 0,
ScrollBegin,