diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2009-10-16 16:26:06 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2009-10-16 16:26:06 (GMT) |
commit | af1fa7fe766980210d7363c1559197f34b10d834 (patch) | |
tree | e2964649ca8469269950a265060b3d1e7e6026f6 /src/corelib/plugin/quuid.cpp | |
parent | c5bfbe27f5bbdb1f3e76af8ca5e0f4df27875a06 (diff) | |
parent | 1433a2c8682cb1c8f89ceaf97ad7a509ac686879 (diff) | |
download | Qt-af1fa7fe766980210d7363c1559197f34b10d834.zip Qt-af1fa7fe766980210d7363c1559197f34b10d834.tar.gz Qt-af1fa7fe766980210d7363c1559197f34b10d834.tar.bz2 |
Merge branch '4.6'
Conflicts:
translations/assistant_adp_pl.ts
translations/assistant_adp_ru.ts
Diffstat (limited to 'src/corelib/plugin/quuid.cpp')
-rw-r--r-- | src/corelib/plugin/quuid.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp index 7224ad3..3c79653 100644 --- a/src/corelib/plugin/quuid.cpp +++ b/src/corelib/plugin/quuid.cpp @@ -548,9 +548,11 @@ bool QUuid::operator>(const QUuid &other) const On any platform other than Windows, this function returns a new UUID with variant QUuid::DCE and version QUuid::Random. The random numbers used to construct the UUID are obtained from the local - pseudo-random generator, which is usually not a cryptographic + pseudo-random generator, qrand(), which is usually not a cryptographic quality random number generator. Therefore, a UUID generated by - this function can't be guaranteed to be unique. + this function can't be guaranteed to be unique. If the pseudo-random + number generator for the calling thread has not yet been seeded, this + function will seed the pseudo-random number generator by calling qsrand(). On a Windows platform, a GUID is generated, which almost certainly \e{will} be unique, on this or any other system, networked or not. @@ -578,6 +580,8 @@ QT_BEGIN_INCLUDE_NAMESPACE #include "stdlib.h" // For srand/rand QT_END_INCLUDE_NAMESPACE +extern void qsrand(); // in qglobal.cpp + QUuid QUuid::createUuid() { static const int intbits = sizeof(int)*8; @@ -585,10 +589,11 @@ QUuid QUuid::createUuid() if (!randbits) { int max = RAND_MAX; do { ++randbits; } while ((max=max>>1)); - qsrand((uint)QDateTime::currentDateTime().toTime_t()); - qrand(); // Skip first } + // reseed, but only if not already seeded + qsrand(); + QUuid result; uint *data = &(result.data1); int chunks = 16 / sizeof(uint); |