summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qglobal.cpp
diff options
context:
space:
mode:
authoraxis <qt-info@nokia.com>2009-11-06 14:50:21 (GMT)
committeraxis <qt-info@nokia.com>2009-11-06 14:50:21 (GMT)
commitd1aa89647824cbaf9af4fc943d4514018973ddc1 (patch)
treee8e13c32613a896311117fc39c45fe8b6f27144d /src/corelib/global/qglobal.cpp
parent351ba8b9ca4f0db176c9e3553d105be0ef35c844 (diff)
parentdaf5f511ee813fc4fffba64bed558d0413270388 (diff)
downloadQt-d1aa89647824cbaf9af4fc943d4514018973ddc1.zip
Qt-d1aa89647824cbaf9af4fc943d4514018973ddc1.tar.gz
Qt-d1aa89647824cbaf9af4fc943d4514018973ddc1.tar.bz2
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/qt
Diffstat (limited to 'src/corelib/global/qglobal.cpp')
-rw-r--r--src/corelib/global/qglobal.cpp93
1 files changed, 64 insertions, 29 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 907be24..f630f96 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -965,7 +965,7 @@ QT_BEGIN_NAMESPACE
\relates <QtGlobal>
Turns the major, minor and patch numbers of a version into an
- integer, 0xMMNNPP (MM = major, NN = minor, PP = patch). This can
+ integer, 0xMMNNPP (MM = major, NN = minor, PP = patch). This can
be compared with another similarly processed version id.
\sa QT_VERSION
@@ -1196,6 +1196,10 @@ bool qSharedBuild()
\value SV_9_2 Symbian OS v9.2
\value SV_9_3 Symbian OS v9.3
\value SV_9_4 Symbian OS v9.4
+ \value SV_SF_1 Symbian^1
+ \value SV_SF_2 Symbian^2
+ \value SV_SF_3 Symbian^3
+ \value SV_SF_4 Symbian^4
\value SV_Unknown An unknown and currently unsupported platform
\sa S60Version, WinVersion, MacVersion
@@ -1212,6 +1216,8 @@ bool qSharedBuild()
\value SV_S60_3_1 S60 3rd Edition Feature Pack 1
\value SV_S60_3_2 S60 3rd Edition Feature Pack 2
\value SV_S60_5_0 S60 5th Edition
+ \value SV_S60_5_1 S60 5th Edition Feature Pack 1
+ \value SV_S60_5_2 S60 5th Edition Feature Pack 2
\value SV_S60_Unknown An unknown and currently unsupported platform
\omitvalue SV_S60_None
@@ -1800,7 +1806,7 @@ QSysInfo::S60Version QSysInfo::s60Version()
TInt err = fileFinder.FindWildByDir(qt_S60Filter, qt_S60SystemInstallDir, contents);
if (err == KErrNone) {
err = contents->Sort(EDescending|ESortByName);
- if (err == KErrNone) {
+ if (err == KErrNone && contents->Count() > 0 && (*contents)[0].iName.Length() >= 12) {
TInt major = (*contents)[0].iName[9] - '0';
TInt minor = (*contents)[0].iName[11] - '0';
if (major == 3) {
@@ -1813,6 +1819,12 @@ QSysInfo::S60Version QSysInfo::s60Version()
if (minor == 0) {
return cachedS60Version = SV_S60_5_0;
}
+ else if (minor == 1) {
+ return cachedS60Version = SV_S60_5_1;
+ }
+ else if (minor == 2) {
+ return cachedS60Version = SV_S60_5_2;
+ }
}
}
delete contents;
@@ -1827,12 +1839,10 @@ QSysInfo::S60Version QSysInfo::s60Version()
return cachedS60Version = SV_S60_3_2;
# elif defined(__S60_50__)
return cachedS60Version = SV_S60_5_0;
-# else
- return cachedS60Version = SV_S60_Unknown;
# endif
-# else
- return cachedS60Version = SV_S60_Unknown;
# endif
+ //If reaching here, it was not possible to determine the version
+ return cachedS60Version = SV_S60_Unknown;
}
QSysInfo::SymbianVersion QSysInfo::symbianVersion()
{
@@ -1843,6 +1853,10 @@ QSysInfo::SymbianVersion QSysInfo::symbianVersion()
return SV_9_3;
case SV_S60_5_0:
return SV_9_4;
+ case SV_S60_5_1:
+ return SV_9_4;
+ case SV_S60_5_2:
+ return SV_9_4;
default:
return SV_Unknown;
}
@@ -2518,10 +2532,19 @@ Q_GLOBAL_STATIC(SeedStorage, randTLS) // Thread Local Storage for seed value
void qsrand(uint seed)
{
#if defined(Q_OS_UNIX) && !defined(QT_NO_THREAD) && !defined(Q_OS_SYMBIAN)
- SeedStorageType *pseed = randTLS()->localData();
- if (!pseed)
- randTLS()->setLocalData(pseed = new SeedStorageType);
- *pseed = seed;
+ SeedStorage *seedStorage = randTLS();
+ if (seedStorage) {
+ SeedStorageType *pseed = seedStorage->localData();
+ if (!pseed)
+ seedStorage->setLocalData(pseed = new SeedStorageType);
+ *pseed = seed;
+ } else {
+ //golbal static seed storage should always exist,
+ //except after being deleted by QGlobalStaticDeleter.
+ //But since it still can be called from destructor of another
+ //global static object, fallback to sqrand(seed)
+ srand(seed);
+ }
#else
// On Windows srand() and rand() already use Thread-Local-Storage
// to store the seed between calls
@@ -2541,21 +2564,24 @@ void qsrand(uint seed)
void qsrand()
{
#if (defined(Q_OS_UNIX) || defined(Q_OS_WIN)) && !defined(QT_NO_THREAD) && !defined(Q_OS_SYMBIAN)
- SeedStorageType *pseed = randTLS()->localData();
- if (pseed) {
- // already seeded
- return;
- }
- randTLS()->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);
+ 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)
- // for Windows the srand function must still be called.
- srand(*pseed);
+ // for Windows the srand function must still be called.
+ srand(*pseed);
#endif
+ }
#elif defined(Q_OS_WIN)
static unsigned int seed = 0;
@@ -2565,7 +2591,7 @@ void qsrand()
seed = GetTickCount();
srand(seed);
-#else
+#else
// Symbian?
#endif // defined(Q_OS_UNIX) || defined(Q_OS_WIN)) && !defined(QT_NO_THREAD) && !defined(Q_OS_SYMBIAN)
@@ -2589,12 +2615,21 @@ void qsrand()
int qrand()
{
#if defined(Q_OS_UNIX) && !defined(QT_NO_THREAD) && !defined(Q_OS_SYMBIAN)
- SeedStorageType *pseed = randTLS()->localData();
- if (!pseed) {
- randTLS()->setLocalData(pseed = new SeedStorageType);
- *pseed = 1;
+ SeedStorage *seedStorage = randTLS();
+ if (seedStorage) {
+ SeedStorageType *pseed = seedStorage->localData();
+ if (!pseed) {
+ seedStorage->setLocalData(pseed = new SeedStorageType);
+ *pseed = 1;
+ }
+ return rand_r(pseed);
+ } else {
+ //golbal static seed storage should always exist,
+ //except after being deleted by QGlobalStaticDeleter.
+ //But since it still can be called from destructor of another
+ //global static object, fallback to qrand()
+ return rand();
}
- return rand_r(pseed);
#else
// On Windows srand() and rand() already use Thread-Local-Storage
// to store the seed between calls