diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2010-07-15 13:08:38 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2010-07-15 13:08:38 (GMT) |
commit | 8cda4ebd5611a6680cd311ff7cadfcc43c6f1686 (patch) | |
tree | 9f1813234d33b577951e21eee7d81f65c1f20769 /src/corelib/plugin | |
parent | 03c01176ebf423085e56ceabcf8335ca5027a786 (diff) | |
parent | 77edce14629b665924e89b1f22f902ceb010c964 (diff) | |
download | Qt-8cda4ebd5611a6680cd311ff7cadfcc43c6f1686.zip Qt-8cda4ebd5611a6680cd311ff7cadfcc43c6f1686.tar.gz Qt-8cda4ebd5611a6680cd311ff7cadfcc43c6f1686.tar.bz2 |
Merge remote branch 'origin/4.6' into qt-4.7-from-4.6
Conflicts:
bin/syncqt
src/3rdparty/webkit/VERSION
src/3rdparty/webkit/WebCore/ChangeLog
src/3rdparty/webkit/WebCore/bridge/qt/qt_instance.cpp
src/3rdparty/webkit/WebCore/bridge/qt/qt_runtime.h
src/3rdparty/webkit/WebCore/page/FrameView.cpp
src/3rdparty/webkit/WebCore/page/FrameView.h
src/3rdparty/webkit/WebCore/platform/ScrollView.cpp
src/3rdparty/webkit/WebCore/platform/ScrollView.h
src/corelib/plugin/quuid.cpp
src/gui/dialogs/qfontdialog.cpp
src/multimedia/audio/qaudiodevicefactory.cpp
src/opengl/qgl.cpp
src/openvg/qpaintengine_vg.cpp
tests/auto/qxmlquery/tst_qxmlquery.cpp
Diffstat (limited to 'src/corelib/plugin')
-rw-r--r-- | src/corelib/plugin/quuid.cpp | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp index 9332bbc..6c1b6e7 100644 --- a/src/corelib/plugin/quuid.cpp +++ b/src/corelib/plugin/quuid.cpp @@ -578,11 +578,10 @@ QUuid QUuid::createUuid() QT_BEGIN_INCLUDE_NAMESPACE #include "qdatetime.h" #include "qfile.h" -#include "stdlib.h" // For srand/rand +#include "qthreadstorage.h" +#include <stdlib.h> // for RAND_MAX QT_END_INCLUDE_NAMESPACE -extern void qsrand(); // in qglobal.cpp - QUuid QUuid::createUuid() { QUuid result; @@ -600,12 +599,32 @@ QUuid QUuid::createUuid() static const int intbits = sizeof(int)*8; static int randbits = 0; if (!randbits) { + int r = 0; int max = RAND_MAX; - do { ++randbits; } while ((max=max>>1)); + do { ++r; } while ((max=max>>1)); + randbits = r; } - // reseed, but only if not already seeded - qsrand(); + // Seed the PRNG once per thread with a combination of current time, a + // stack address and a serial counter (since thread stack addresses are + // re-used). +#ifndef QT_BOOTSTRAPPED + static QThreadStorage<int *> uuidseed; + if (!uuidseed.hasLocalData()) + { + int *pseed = new int; + static QBasicAtomicInt serial = Q_BASIC_ATOMIC_INITIALIZER(2); + qsrand(*pseed = QDateTime::currentDateTime().toTime_t() + + quintptr(&pseed) + + serial.fetchAndAddRelaxed(1)); + uuidseed.setLocalData(pseed); + } +#else + static bool seeded = false; + if (!seeded) + qsrand(QDateTime::currentDateTime().toTime_t() + + quintptr(&seeded)); +#endif int chunks = 16 / sizeof(uint); while (chunks--) { |