qt5base-lts/tests/auto/corelib/kernel
Marc Mutz e80faf3db6 QTimer: don't circumvent <chrono> safety net
By templating on the <chrono> types and unconditionally using
duration_cast to coerce the duration into a milliseconds, we
violate a principal design rule of <chrono>, namely that non-
narrowing conversions are implicit, but narrowing conversions
need duration_cast. By accepting any duration, we allow non-
sensical code such as

   QTimer::singleShot(10us, ...)

to compile, which is misleading, since it's actually a zero-
timeout timer.

Overloading a non-template with a template also has adverse
effects: it breaks qOverload().

Fix by replacing the function templates with functions that
just take std::chrono::milliseconds. This way, benign code
such as

    QTimer::singleShot(10s, ...)
    QTimer::singleShot(10min, ...)
    QTimer::singleShot(1h, ...)

work as expected, but attempts to use sub-millisecond
resolution fails to compile / needs an explicit user-
provided duration_cast.

To allow future extension to more precise timers, forcibly
inline the functions, so they don't partake in the ABI of the
class and we can later support sub-millisecond resolution by
simply taking micro- or nano- instead of milliseconds.

Change-Id: I12c9a98bdabefcd8ec18a9eb09f87ad908d889de
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-10-18 16:06:28 +00:00
..
qcoreapplication Use qtConfig throughout in qtbase 2016-08-19 04:28:05 +00:00
qdeadlinetimer Long live QDeadlineTimer 2016-08-15 03:07:16 +00:00
qelapsedtimer Move QElapsedTimer to src/corelib/kernel 2016-07-02 07:51:45 +00:00
qeventdispatcher Updated license headers 2016-01-21 18:55:18 +00:00
qeventloop Use qtConfig throughout in qtbase 2016-08-19 04:28:05 +00:00
qmath Updated license headers 2016-01-21 18:55:18 +00:00
qmetaenum Updated license headers 2016-01-21 18:55:18 +00:00
qmetamethod Updated license headers 2016-01-21 18:55:18 +00:00
qmetaobject Add a function to QMetaObject to check for inheritance 2016-03-15 16:36:22 +00:00
qmetaobjectbuilder Updated license headers 2016-01-21 18:55:18 +00:00
qmetaproperty Updated license headers 2016-01-21 18:55:18 +00:00
qmetatype Use extreme values in QMetaType/QSettings test data 2016-10-05 20:31:23 +00:00
qmimedata Updated license headers 2016-01-21 18:55:18 +00:00
qobject Merge remote-tracking branch 'origin/5.7' into 5.8 2016-09-29 00:38:01 +02:00
qpointer Merge remote-tracking branch 'origin/5.6' into 5.7 2016-04-04 08:59:18 +02:00
qsharedmemory QtCore: Remove Windows CE. 2016-03-30 11:22:47 +00:00
qsignalblocker Updated license headers 2016-01-21 18:55:18 +00:00
qsignalmapper Updated license headers 2016-01-21 18:55:18 +00:00
qsocketnotifier Use qtConfig throughout in qtbase 2016-08-19 04:28:05 +00:00
qsystemsemaphore Updated license headers 2016-01-21 18:55:18 +00:00
qtimer QTimer: don't circumvent <chrono> safety net 2016-10-18 16:06:28 +00:00
qtranslator Remove the traces of the discontinued android-no-sdk platform 2016-03-30 10:12:34 +00:00
qvariant Use qtConfig throughout in qtbase 2016-08-19 04:28:05 +00:00
qwineventnotifier Updated license headers 2016-01-21 18:55:18 +00:00
kernel.pro Use qtConfig throughout in qtbase 2016-08-19 04:28:05 +00:00