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 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; - static_assert(ratio::den == 1); - - Duration::rep r; - if (qMulOverflow(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; + static_assert(ratio::den == 1); + + Duration::rep r; + if (qMulOverflow(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); } }