summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/global/qglobal.cpp58
-rw-r--r--src/corelib/plugin/quuid.cpp13
-rw-r--r--src/gui/dialogs/qfontdialog.cpp1
3 files changed, 14 insertions, 58 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 66519be..b24ba38 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -2586,55 +2586,6 @@ void qsrand(uint seed)
#endif
}
-/*! \internal
- \relates <QtGlobal>
- \since 4.6
-
- Seed the PRNG, but only if it has not already been seeded.
-
- The default seed is a combination of current time, a stack address and a
- serial counter (since thread stack addresses are re-used).
-*/
-void qsrand()
-{
-#if (defined(Q_OS_UNIX) || defined(Q_OS_WIN)) && !defined(QT_NO_THREAD)
- SeedStorage *seedStorage = randTLS();
- if (seedStorage) {
- SeedStorageType *pseed = seedStorage->localData();
- if (pseed) {
- // already seeded
- return;
- }
- seedStorage->setLocalData(pseed = new SeedStorageType);
- // start beyond 1 to avoid the sequence reset
- static QBasicAtomicInt serial = Q_BASIC_ATOMIC_INITIALIZER(2);
- *pseed = QDateTime::currentDateTime().toTime_t()
- + quintptr(&pseed)
- + serial.fetchAndAddRelaxed(1);
-#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
- // for Windows and Symbian the srand function must still be called.
- srand(*pseed);
-#endif
- }
-
-//QT_NO_THREAD implementations
-#else
- static unsigned int seed = 0;
-
- if (seed)
- return;
-
-#if defined(Q_OS_SYMBIAN)
- seed = Math::Random();
-#elif defined(Q_OS_WIN)
- seed = GetTickCount();
-#else
- seed = quintptr(&seed) + QDateTime::currentDateTime().toTime_t();
-#endif
- srand(seed);
-#endif // defined(Q_OS_UNIX) || defined(Q_OS_WIN)) && !defined(QT_NO_THREAD)
-}
-
/*!
\relates <QtGlobal>
\since 4.2
@@ -2658,7 +2609,14 @@ int qrand()
SeedStorageType *pseed = seedStorage->localData();
if (!pseed) {
seedStorage->setLocalData(pseed = new SeedStorageType);
- *pseed = 1;
+
+ // Seed the PRNG, but only if it has not already been seeded. The
+ // default seed is a combination of current time, a stack address
+ // and a serial counter (since thread stack addresses are re-used).
+ static QBasicAtomicInt serial = Q_BASIC_ATOMIC_INITIALIZER(2);
+ *pseed = QDateTime::currentDateTime().toTime_t()
+ + quintptr(&pseed)
+ + serial.fetchAndAddRelaxed(1);
}
return rand_r(pseed);
} else {
diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp
index 8541c7d..f48cc2e 100644
--- a/src/corelib/plugin/quuid.cpp
+++ b/src/corelib/plugin/quuid.cpp
@@ -577,23 +577,20 @@ QUuid QUuid::createUuid()
QT_BEGIN_INCLUDE_NAMESPACE
#include "qdatetime.h"
-#include "stdlib.h" // For srand/rand
+#include <stdlib.h> // for RAND_MAX
QT_END_INCLUDE_NAMESPACE
-extern void qsrand(); // in qglobal.cpp
-
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();
-
QUuid result;
uint *data = &(result.data1);
int chunks = 16 / sizeof(uint);
@@ -601,7 +598,7 @@ QUuid QUuid::createUuid()
uint randNumber = 0;
for (int filled = 0; filled < intbits; filled += randbits)
randNumber |= qrand()<<filled;
- *(data+chunks) = randNumber;
+ *(data+chunks) = randNumber;
}
result.data4[0] = (result.data4[0] & 0x3F) | 0x80; // UV_DCE
diff --git a/src/gui/dialogs/qfontdialog.cpp b/src/gui/dialogs/qfontdialog.cpp
index a4bf15d..e9e3f23 100644
--- a/src/gui/dialogs/qfontdialog.cpp
+++ b/src/gui/dialogs/qfontdialog.cpp
@@ -332,6 +332,7 @@ void QFontDialogPrivate::init()
#ifdef Q_WS_MAC
delegate = 0;
+ nativeDialogInUse = false;
#endif
}