Details
-
Bug
-
Resolution: Done
-
P4: Low
-
5.4.2, 5.12.0 Alpha
-
None
-
-
aa18467442011a8ad26ca6396c2bb44f44aba569 (qt/qtbase/5.12)
Description
On Windows, QThread::usleep is implemented like this:
https://github.com/qt/qtbase/blob/5.11/src/corelib/thread/qthread_win.cpp#L464
i.e. it lies to you and actually calls a Sleep which is millisecond precise.
This is bad thing because this makes the user thinks QThread:usleep is microsecond accurate, and it's not.
I know sleep functions are not reliable by nature, but here Qt is intentionally loosing precision on the number passed to the QThread::usleep function.
Removing the function from Qt for Windows would make clear that QThread's sleep can't be microsecond precise on Windows.
This will not be source compatible, and cause issues when porting Qt code from Unix to Windows, but IMO letting some Unix migrated code calling QThread::usleep on Windows silently compiles without any error is misleading, because it hides potential issues on the loose of precision.
At least a message on the documentation would be nice.