Details
-
Bug
-
Resolution: Done
-
P4: Low
-
4.6.0, 4.6.1, 4.6.2
-
None
Description
If the following program is run on the same box twice within the same second, then the same UUID returned.
---------------------------
#include <stdio.h>
#include <QUuid>
int main(int argc, char *argv[]) {
fprintf(stdout, "%s\n", qPrintable(QUuid::createUuid().toString()));
return 0;
}
----------------------------
The reason for this is that qsrand() (not qsrand(int)) in 4.6.x in src/corelib/global/qglobal.cpp doesn't distinguish on something that is process specific. It has time-specific & thread-specific (thanks to QTBUG-3543) descrimination, but not process-specific.
To fix this, for both Unix & Windows, it should be as simple as adding in the process ID of the current process:
Unix: + quint32(getpid())
Windows: + quint32(GetCurrentProcessId())