summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorA-Team <ateam@pad.test.qt.nokia.com>2010-10-07 22:00:16 (GMT)
committerA-Team <ateam@pad.test.qt.nokia.com>2010-10-07 22:00:16 (GMT)
commit8130fcbffe365c0e019f45baae7f1b273d8e17e7 (patch)
tree91cebf29af4336d2010fe66460d586f605a72ab0 /src/corelib
parent0f9d642e105da1644f4ed846a696510f9a9f1daf (diff)
parent161f15e1e79ec5f23244da68340ba1e78f3ac4bb (diff)
downloadQt-8130fcbffe365c0e019f45baae7f1b273d8e17e7.zip
Qt-8130fcbffe365c0e019f45baae7f1b273d8e17e7.tar.gz
Qt-8130fcbffe365c0e019f45baae7f1b273d8e17e7.tar.bz2
Merge branch '4.7-upstream' into 4.7-doc
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/global/qnamespace.qdoc2
-rw-r--r--src/corelib/plugin/quuid.cpp67
-rw-r--r--src/corelib/thread/qthreadstorage.cpp21
-rw-r--r--src/corelib/tools/qregexp.cpp4
-rw-r--r--src/corelib/tools/qstring.cpp2
5 files changed, 63 insertions, 33 deletions
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index 32e85db..1c41eca 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -2771,7 +2771,7 @@
\value ElideNone Ellipsis should NOT appear in the text.
Qt::ElideMiddle is normally the most appropriate choice for URLs (e.g.,
- "\l{http://qt.nokia.com/careers/movingto/brisbane/}{http://qt.nok...ovingto/brisbane/}"),
+ "\l{http://bugreports.qt.nokia.com/browse/QTWEBSITE-13}{http://bugreports.qt.../QTWEBSITE-13/}"),
whereas Qt::ElideRight is appropriate
for other strings (e.g.,
"\l{http://qt.nokia.com/doc/qq/qq09-mac-deployment.html}{Deploying Applications on Ma...}").
diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp
index 6c1b6e7..983d249 100644
--- a/src/corelib/plugin/quuid.cpp
+++ b/src/corelib/plugin/quuid.cpp
@@ -582,48 +582,65 @@ QT_BEGIN_INCLUDE_NAMESPACE
#include <stdlib.h> // for RAND_MAX
QT_END_INCLUDE_NAMESPACE
+#if !defined(QT_BOOTSTRAPPED) && defined(Q_OS_UNIX)
+Q_GLOBAL_STATIC(QThreadStorage<QFile *>, devUrandomStorage);
+#endif
+
QUuid QUuid::createUuid()
{
QUuid result;
uint *data = &(result.data1);
-#ifdef Q_OS_UNIX
- QFile devUrandom;
- devUrandom.setFileName(QLatin1String("/dev/urandom"));
- if (devUrandom.open(QIODevice::ReadOnly)) {
- qint64 numToRead = 4 * sizeof(uint);
- devUrandom.read((char *) data, numToRead); // should read 128-bits of data
+#if defined(Q_OS_UNIX)
+ QFile *devUrandom;
+# if !defined(QT_BOOTSTRAPPED)
+ devUrandom = devUrandomStorage()->localData();
+ if (!devUrandom) {
+ devUrandom = new QFile(QLatin1String("/dev/urandom"));
+ devUrandom->open(QIODevice::ReadOnly | QIODevice::Unbuffered);
+ devUrandomStorage()->setLocalData(devUrandom);
+ }
+# else
+ QFile file(QLatin1String("/dev/urandom"));
+ devUrandom = &file;
+ devUrandom->open(QIODevice::ReadOnly | QIODevice::Unbuffered);
+# endif
+ enum { AmountToRead = 4 * sizeof(uint) };
+ if (devUrandom->isOpen()
+ && devUrandom->read((char *) data, AmountToRead) == AmountToRead) {
+ // we got what we wanted, nothing more to do
+ ;
} else
#endif
{
static const int intbits = sizeof(int)*8;
static int randbits = 0;
if (!randbits) {
- int r = 0;
+ int r = 0;
int max = RAND_MAX;
do { ++r; } while ((max=max>>1));
randbits = r;
}
- // 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).
+ // 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);
- }
+ 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));
+ static bool seeded = false;
+ if (!seeded)
+ qsrand(QDateTime::currentDateTime().toTime_t()
+ + quintptr(&seeded));
#endif
int chunks = 16 / sizeof(uint);
@@ -631,7 +648,7 @@ QUuid QUuid::createUuid()
uint randNumber = 0;
for (int filled = 0; filled < intbits; filled += randbits)
randNumber |= qrand()<<filled;
- *(data+chunks) = randNumber;
+ *(data+chunks) = randNumber;
}
}
diff --git a/src/corelib/thread/qthreadstorage.cpp b/src/corelib/thread/qthreadstorage.cpp
index 88d73cc..2fc04f5 100644
--- a/src/corelib/thread/qthreadstorage.cpp
+++ b/src/corelib/thread/qthreadstorage.cpp
@@ -79,6 +79,21 @@ QThreadStorageData::QThreadStorageData(void (*func)(void *))
{
QMutexLocker locker(mutex());
DestructorMap *destr = destructors();
+ if (!destr) {
+ /*
+ the destructors vector has already been destroyed, yet a new
+ QThreadStorage is being allocated. this can only happen during global
+ destruction, at which point we assume that there is only one thread.
+ in order to keep QThreadStorage working, we need somewhere to store
+ the data, best place we have in this situation is at the tail of the
+ current thread's tls vector. the destructor is ignored, since we have
+ no where to store it, and no way to actually call it.
+ */
+ QThreadData *data = QThreadData::current();
+ id = data->tls.count();
+ DEBUG_MSG("QThreadStorageData: Allocated id %d, destructor %p cannot be stored", id, func);
+ return;
+ }
for (id = 0; id < destr->count(); id++) {
if (destr->at(id) == 0)
break;
@@ -139,13 +154,15 @@ void **QThreadStorageData::set(void *p)
data->thread);
QMutexLocker locker(mutex());
- void (*destructor)(void *) = destructors()->value(id);
+ DestructorMap *destr = destructors();
+ void (*destructor)(void *) = destr ? destr->value(id) : 0;
locker.unlock();
void *q = value;
value = 0;
- destructor(q);
+ if (destructor)
+ destructor(q);
}
// store new data
diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp
index 36827d0..a8bf38f 100644
--- a/src/corelib/tools/qregexp.cpp
+++ b/src/corelib/tools/qregexp.cpp
@@ -74,10 +74,6 @@ int qFindString(const QChar *haystack, int haystackLen, int from,
#define RXERR_INTERVAL QT_TRANSLATE_NOOP("QRegExp", "invalid interval")
#define RXERR_CATEGORY QT_TRANSLATE_NOOP("QRegExp", "invalid category")
-/*
- WARNING! Be sure to read qregexp.tex before modifying this file.
-*/
-
/*!
\class QRegExp
\reentrant
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index ff9d877..d8dab43 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -565,7 +565,7 @@ const QString::Null QString::null = { };
and join a list of strings into a single string with an optional
separator using QStringList::join(). You can obtain a list of
strings from a string list that contain a particular substring or
- that match a particular QRegExp using the QStringList::find()
+ that match a particular QRegExp using the QStringList::filter()
function.
:
\section1 Querying String Data