diff options
| author | Marc Mutz <marc.mutz@qt.io> | 2024-06-28 10:18:20 +0200 |
|---|---|---|
| committer | Marc Mutz <marc.mutz@qt.io> | 2024-07-12 17:36:16 +0000 |
| commit | ba80845ed16b784ac00dcc9e7715e4605e3344ff (patch) | |
| tree | 388a4836db7df816b048a7e5b8f40ae7643a23a0 /src | |
| parent | 10b7b7fcf06d4ed5492e946ac93eb232c168e686 (diff) | |
QSingleShotTimer: de-inline [3/4]: move fromMSecs to qtimer.cpp
Move the implementation of fromSecs() from the header to the
qtimer.cpp file and make it file-static. There are no callers of the
function outside qtimer.cpp.
Amends e0573e73645c0f57e46332a94160e28eb6c8ebac.
As a drive-by, rename the function to snake_case to indicate that it's
a file-static.
Pick-to: 6.8
Change-Id: Ifa32df8a28816cd9cae44cdb9d481df94d33d741
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/corelib/kernel/qsingleshottimer_p.h | 18 | ||||
| -rw-r--r-- | src/corelib/kernel/qtimer.cpp | 21 |
2 files changed, 19 insertions, 20 deletions
diff --git a/src/corelib/kernel/qsingleshottimer_p.h b/src/corelib/kernel/qsingleshottimer_p.h index 11354e0b9e5..800936a30de 100644 --- a/src/corelib/kernel/qsingleshottimer_p.h +++ b/src/corelib/kernel/qsingleshottimer_p.h @@ -19,9 +19,6 @@ #include "qabstracteventdispatcher.h" #include "qcoreapplication.h" #include "qmetaobject_p.h" -#include "private/qnumeric_p.h" - -#include <chrono> QT_BEGIN_NAMESPACE @@ -43,21 +40,6 @@ public: void startTimerForReceiver(Duration interval, Qt::TimerType timerType, const QObject *receiver); - - static Duration fromMsecs(std::chrono::milliseconds ms) - { - using namespace std::chrono; - using ratio = std::ratio_divide<std::milli, Duration::period>; - static_assert(ratio::den == 1); - - Duration::rep r; - if (qMulOverflow<ratio::num>(ms.count(), &r)) { - qWarning("QTimer::singleShot(std::chrono::milliseconds, ...): " - "interval argument overflowed when converted to nanoseconds."); - return Duration::max(); - } - return Duration{r}; - } Q_SIGNALS: void timeout(); diff --git a/src/corelib/kernel/qtimer.cpp b/src/corelib/kernel/qtimer.cpp index 8d3ea7865d6..362285e3694 100644 --- a/src/corelib/kernel/qtimer.cpp +++ b/src/corelib/kernel/qtimer.cpp @@ -288,6 +288,23 @@ void QTimer::timerEvent(QTimerEvent *e) } } +static QAbstractEventDispatcher::Duration from_msecs(std::chrono::milliseconds ms) +{ + using Duration = QAbstractEventDispatcher::Duration; + + using namespace std::chrono; + using ratio = std::ratio_divide<std::milli, Duration::period>; + static_assert(ratio::den == 1); + + Duration::rep r; + if (qMulOverflow<ratio::num>(ms.count(), &r)) { + qWarning("QTimer::singleShot(std::chrono::milliseconds, ...): " + "interval argument overflowed when converted to nanoseconds."); + return Duration::max(); + } + return Duration{r}; +} + /*! \internal @@ -332,7 +349,7 @@ void QTimer::singleShotImpl(std::chrono::milliseconds msec, Qt::TimerType timerT return; } - new QSingleShotTimer(QSingleShotTimer::fromMsecs(msec), timerType, receiver, slotObj); + new QSingleShotTimer(from_msecs(msec), timerType, receiver, slotObj); } /*! @@ -396,7 +413,7 @@ void QTimer::singleShot(std::chrono::milliseconds msec, Qt::TimerType timerType, Qt::QueuedConnection); return; } - (void) new QSingleShotTimer(QSingleShotTimer::fromMsecs(msec), timerType, receiver, member); + (void) new QSingleShotTimer(from_msecs(msec), timerType, receiver, member); } } |
