qt6-bb10/tests/auto/corelib
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
..
animation QtCore: Remove Windows CE. 2016-03-30 11:22:47 +00:00
codecs tests/auto/corelib/codecs: clean up 2016-08-06 14:49:21 +00:00
global Use qtConfig throughout in qtbase 2016-08-19 04:28:05 +00:00
io tst_QSettings: Don't assume the presence of a key means isWritable 2016-10-10 16:06:43 +00:00
itemmodels Merge remote-tracking branch 'origin/5.7' into dev 2016-08-16 07:58:32 +02:00
json Modularize configure.json/.pri 2016-09-15 08:23:53 +00:00
kernel QTimer: don't circumvent <chrono> safety net 2016-10-18 16:06:28 +00:00
mimetypes tests/auto/corelib/mimetypes: use local QThreadPool 2016-09-17 06:47:05 +00:00
plugin Convert the old feature system 2016-09-15 08:24:10 +00:00
statemachine Merge "Merge remote-tracking branch 'origin/5.6' into dev" into refs/staging/dev 2016-01-26 11:27:37 +00:00
thread winrt: Make test functional 2016-08-09 12:13:23 +00:00
tools Round to nearest millisecond in QDateTime::fromCFDate() 2016-10-02 13:07:18 +00:00
xml tests/auto/corelib/xml: cleanup 2016-08-27 05:09:16 +00:00
corelib.pro Add support for Apple tvOS 2016-05-17 16:11:23 +00:00