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. Change-Id: Ifa32df8a28816cd9cae44cdb9d481df94d33d741 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit ba80845ed16b784ac00dcc9e7715e4605e3344ff) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
4e209c2188
commit
431ca49614
@ -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();
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user