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 | |
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')
-rw-r--r-- | src/corelib/concurrent/qtconcurrentmap.cpp | 2 | ||||
-rw-r--r-- | src/corelib/global/qglobal.cpp | 49 | ||||
-rw-r--r-- | src/corelib/io/qfsfileengine_unix.cpp | 4 | ||||
-rw-r--r-- | src/corelib/plugin/quuid.cpp | 31 | ||||
-rw-r--r-- | src/corelib/tools/qsharedpointer_impl.h | 31 |
5 files changed, 45 insertions, 72 deletions
diff --git a/src/corelib/concurrent/qtconcurrentmap.cpp b/src/corelib/concurrent/qtconcurrentmap.cpp index 39a13fb..e74d69c 100644 --- a/src/corelib/concurrent/qtconcurrentmap.cpp +++ b/src/corelib/concurrent/qtconcurrentmap.cpp @@ -70,7 +70,7 @@ \value UnorderedReduce Reduction is done in an arbitrary order. \value OrderedReduce Reduction is done in the order of the original sequence. - \value SequentialReduce Reduction is done sequentally: only one + \value SequentialReduce Reduction is done sequentially: only one thread will enter the reduce function at a time. (Parallel reduction might be supported in a future version of Qt Concurrent.) */ diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 75a51ec..c956b85 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -2606,55 +2606,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 diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index 9464a97..d83f7ee 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -1023,7 +1023,7 @@ QString QFSFileEngine::fileName(FileName file) const #if !defined(QWS) && defined(Q_OS_MAC) QCFType<CFURLRef> url = CFURLCreateWithFileSystemPath(0, QCFString(d->filePath), kCFURLPOSIXPathStyle, true); - if (CFDictionaryRef dict = CFBundleCopyInfoDictionaryForURL(url)) { + if (QCFType<CFDictionaryRef> dict = CFBundleCopyInfoDictionaryForURL(url)) { if (CFTypeRef name = (CFTypeRef)CFDictionaryGetValue(dict, kCFBundleNameKey)) { if (CFGetTypeID(name) == CFStringGetTypeID()) return QCFString::toQString((CFStringRef)name); @@ -1141,7 +1141,7 @@ QString QFSFileEngine::fileName(FileName file) const if (FSResolveAliasFile(&fref, true, &isFolder, &isAlias) == noErr && isAlias) { AliasHandle alias; if (FSNewAlias(0, &fref, &alias) == noErr && alias) { - CFStringRef cfstr; + QCFString cfstr; if (FSCopyAliasInfo(alias, 0, 0, &cfstr, 0, 0) == noErr) return QCFString::toQString(cfstr); } 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--) { diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 550ff58..4cce339 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -324,12 +324,17 @@ namespace QtSharedPointer { typedef ExternalRefCountData Data; inline void ref() const { d->weakref.ref(); d->strongref.ref(); } - inline bool deref() + inline void deref() + { deref(d, this->value); } + static inline void deref(Data *d, T *value) { + if (!d) return; if (!d->strongref.deref()) { - internalDestroy(); + if (!d->destroy()) + delete value; } - return d->weakref.deref(); + if (!d->weakref.deref()) + delete d; } inline void internalConstruct(T *ptr) @@ -378,7 +383,7 @@ namespace QtSharedPointer { template <class X> inline ExternalRefCount(const ExternalRefCount<X> &other) : Basic<T>(other.value), d(other.d) { if (d) ref(); } - inline ~ExternalRefCount() { if (d && !deref()) delete d; } + inline ~ExternalRefCount() { deref(); } template <class X> inline void internalCopy(const ExternalRefCount<X> &other) @@ -386,12 +391,6 @@ namespace QtSharedPointer { internalSet(other.d, other.data()); } - inline void internalDestroy() - { - if (!d->destroy()) - delete this->value; - } - inline void internalSwap(ExternalRefCount &other) { qSwap(d, other.d); @@ -424,10 +423,14 @@ namespace QtSharedPointer { else o = 0; } - if (d && !deref()) - delete d; - d = o; - this->value = d && d->strongref ? actual : 0; + + qSwap(d, o); + qSwap(this->value, actual); + if (!d || d->strongref == 0) + this->value = 0; + + // dereference saved data + deref(o, actual); } Data *d; |