summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qchronotimer.cpp
diff options
context:
space:
mode:
authorAhmad Samir <a.samirh78@gmail.com>2023-11-18 20:09:49 +0200
committerAhmad Samir <a.samirh78@gmail.com>2024-03-03 19:56:55 +0200
commit577a3dba521f7f69bf6129fcd28184ae288182d9 (patch)
tree5e28ffe662343604cac580188ed2b55fe0b78e0d /src/corelib/kernel/qchronotimer.cpp
parentbd764cc1ca578759f16fbe292fbe14a243b7d263 (diff)
Q{Chrono}Timer: de-duplicate some code
Q{Chrono}Timer::isActive() has to use isActiveData so that the bindable property is correctly queried. However in other places in the code we can take a shortcut by checking id > 0. So rename QTimerPrivate::isActiveActualCalculation() to make it more palatable and use it throughout the code. Change-Id: I3378233e553fd860d9f105bba013dc9ffc31a2ba Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/kernel/qchronotimer.cpp')
-rw-r--r--src/corelib/kernel/qchronotimer.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/corelib/kernel/qchronotimer.cpp b/src/corelib/kernel/qchronotimer.cpp
index d67d7ca48fd..4cc8ff59fc4 100644
--- a/src/corelib/kernel/qchronotimer.cpp
+++ b/src/corelib/kernel/qchronotimer.cpp
@@ -133,7 +133,7 @@ QChronoTimer::QChronoTimer(std::chrono::nanoseconds nsec, QObject *parent)
*/
QChronoTimer::~QChronoTimer()
{
- if (d_func()->id != QTimerPrivate::INV_TIMER) // stop running timer
+ if (d_func()->isActive()) // stop running timer
stop();
}
@@ -187,7 +187,7 @@ int QChronoTimer::id() const
void QChronoTimer::start()
{
auto *d = d_func();
- if (d->id != QTimerPrivate::INV_TIMER) // stop running timer
+ if (d->isActive()) // stop running timer
stop();
const auto id = QObject::startTimer(d->intervalDuration, d->type);
if (id > 0) {
@@ -204,7 +204,7 @@ void QChronoTimer::start()
void QChronoTimer::stop()
{
auto *d = d_func();
- if (d->id != QTimerPrivate::INV_TIMER) {
+ if (d->isActive()) {
QObject::killTimer(d->id);
d->id = QTimerPrivate::INV_TIMER;
d->isActiveData.notify();
@@ -286,7 +286,7 @@ void QChronoTimer::setInterval(std::chrono::nanoseconds nsec)
d->intervalDuration.removeBindingUnlessInWrapper();
const bool intervalChanged = nsec != d->intervalDuration.valueBypassingBindings();
d->intervalDuration.setValueBypassingBindings(nsec);
- if (d->id != QTimerPrivate::INV_TIMER) { // Create new timer
+ if (d->isActive()) { // Create new timer
QObject::killTimer(d->id); // Restart timer
const auto id = QObject::startTimer(nsec, d->type);
if (id > 0) {