Details
-
Bug
-
Resolution: Unresolved
-
P4: Low
-
4.5.2, 4.6.1, 5.7.0
-
None
-
Windows XP, Visual Studio 2005
Description
qErrnoWarning(int code, const char* msg, ...) calls qt_error_string(), which uses the FormatMessage() function under Windows. Unfortunately, this API is not meant for errno values, but for error codes returned by GetLastError(). These are not compatible at all.
This can lead to confusing errors from Qt, such as the following (from a real-life situation) :
[Qt Critical] QThread::start: Failed to create thread (The access code is invalid.)
This should have been :
[Qt Critical] QThread::start: Failed to create thread (Not enough space.)
That's because error code 12 means ENOMEM for errno, while it means ERROR_INVALID_ACCESS for GetLastError(). In other words, qErrnoWarning(ENOMEM, "...") prints "The acces code is invalid", instead of "Not enough space".
qErrnoWarning should use strerror(), and qt_error_string() shouldn't be used with errno values, only with GetLastError() values.