qt5base-lts/tests/auto/corelib
Volker Hilsheimer 87535e4e43 QTimer: optimize single shot timers that cross thread
Amend 4d90c4e74a by clarifying why
moving the QSingleShotObject to the receiver's thread is a good
idea. Move that logic into a separate function and use that also
for the string-based connection.

Optimize the implementation by delaying the timer creation until
after we have moved the QSingleShotTimer object to the target
thread, using a queued metacall if needed to create the timer.
This avoids the creation of the timer in the wrong thread and
then the recreation of the timer in the new thread when QObject
handles QEvent::ThreadChange.

To avoid that the timer is created when it has already expired in
real time, use a deadline timer and fire timeout immediately when
it has expired by the time we get the metacall.

Since the timerId might now not be initialized in the constructor,
initialize it to -1.

Augment the crossThreadSingleShotToFunctor test function by
deliberately not starting the thread until the deadline expired.

[ChangeLog][Core][QTimer] Single-shot timers with a string-based
connection are now started in the receiver's thread, not in the
thread that creates the timer.

Task-number: QTBUG-112162
Change-Id: I3fc94c34c21d9f644da41a2e4c2da479980b8580
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-04-20 20:23:37 +02:00
..
animation tests: Remove remains of qmake conversion from CMakeLists.txt files 2023-02-17 21:56:49 +01:00
global Short live q20::to_address! 2023-03-31 13:10:12 +01:00
io Use LANGUAGE OBJCXX rather than COMPILE_FLAGS "-x objective-c++" 2023-04-13 14:36:26 +02:00
ipc tests: Remove remains of qmake conversion from CMakeLists.txt files 2023-02-17 21:56:49 +01:00
itemmodels Remove unused variables 2023-04-19 12:55:02 +02:00
kernel QTimer: optimize single shot timers that cross thread 2023-04-20 20:23:37 +02:00
mimetypes mimetypes/: port to qsizetype 2023-04-15 17:21:10 +02:00
platform tests: Remove remains of qmake conversion from CMakeLists.txt files 2023-02-17 21:56:49 +01:00
plugin QPluginLoader: don't instantiante multiple, identical instances 2023-04-05 00:29:16 -07:00
serialization QXmlStream: run the test suite from a method other than initTestCase() 2023-04-08 13:23:06 +02:00
text tst_qstringapisymmetry: silence a GCC warning 2023-04-08 13:21:24 +02:00
thread Rid of 'special case' markers 2023-04-13 18:30:58 +02:00
time tst_QDateTime: cope with MET masquerading as CET 2023-04-20 15:17:27 +02:00
tools Remove unused variables 2023-04-19 12:55:02 +02:00
CMakeLists.txt tests: Remove remains of qmake conversion from CMakeLists.txt files 2023-02-17 21:56:49 +01:00