summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-07-13 10:28:56 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-07-13 10:28:56 (GMT)
commit413ad2471afea9f82134942c2c1e5cfe22479139 (patch)
tree2dd641098e6ab1dc9624e35328e99957e91ab00f
parent76da3ecd74ad55fe923eb59f10c1f371611642f4 (diff)
parenta736d333aab9e2e97fdbb738b3f3f4646afe192e (diff)
downloadQt-413ad2471afea9f82134942c2c1e5cfe22479139.zip
Qt-413ad2471afea9f82134942c2c1e5cfe22479139.tar.gz
Qt-413ad2471afea9f82134942c2c1e5cfe22479139.tar.bz2
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.6-integration
* '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-1: Compile when bootstrapping qmake Fix regression in tst_qrand::testqrand() syncqt: don't try to split %module's values syncqt: fix wrong paths in include/ActiveQt/headers.pri Fix a crash when recursing into QSharedPointer from QSharedPointer::clear() Fix a couple of memory leaks due to not releasing CFTypes on Mac Initalize the nativeDialogInUse variable Compile QUUid::createUuid() should not generate identical sequences on UNIX
-rwxr-xr-xbin/syncqt4
-rw-r--r--src/corelib/global/qglobal.cpp49
-rw-r--r--src/corelib/io/qfsfileengine_unix.cpp4
-rw-r--r--src/corelib/plugin/quuid.cpp33
-rw-r--r--src/corelib/tools/qsharedpointer_impl.h31
-rw-r--r--src/gui/dialogs/qfontdialog.cpp1
-rw-r--r--tests/auto/qsharedpointer/tst_qsharedpointer.cpp56
7 files changed, 104 insertions, 74 deletions
diff --git a/bin/syncqt b/bin/syncqt
index db6dce6..d665e87 100755
--- a/bin/syncqt
+++ b/bin/syncqt
@@ -42,7 +42,7 @@ my %modules = ( # path to module name map
"QtScript" => "$basedir/src/script",
"QtScriptTools" => "$basedir/src/scripttools",
"Qt3Support" => "$basedir/src/qt3support",
- "ActiveQt" => "$basedir/src/activeqt/container;$basedir/src/activeqt/control;$basedir/src/activeqt/shared",
+ "ActiveQt" => "$basedir/src/activeqt",
"QtTest" => "$basedir/src/testlib",
"QtAssistant" => "$basedir/tools/assistant/compat/lib",
"QtHelp" => "$basedir/tools/assistant/lib",
@@ -960,7 +960,7 @@ if($check_includes) {
#iteration info
my $lib = $_;
my $dir = "$modules{$lib}";
- foreach (split(/;/, $dir)) {
+ {
my $current_dir = "$_";
#calc subdirs
my @subdirs = ($current_dir);
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 66519be..12745e9 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
diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp
index 33e00f6..76a3512 100644
--- a/src/corelib/io/qfsfileengine_unix.cpp
+++ b/src/corelib/io/qfsfileengine_unix.cpp
@@ -1017,7 +1017,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);
@@ -1135,7 +1135,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 8541c7d..e1d4fc0 100644
--- a/src/corelib/plugin/quuid.cpp
+++ b/src/corelib/plugin/quuid.cpp
@@ -577,22 +577,41 @@ QUuid QUuid::createUuid()
QT_BEGIN_INCLUDE_NAMESPACE
#include "qdatetime.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()
{
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
QUuid result;
uint *data = &(result.data1);
@@ -601,7 +620,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/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h
index 964b279..d581751 100644
--- a/src/corelib/tools/qsharedpointer_impl.h
+++ b/src/corelib/tools/qsharedpointer_impl.h
@@ -323,12 +323,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)
@@ -377,7 +382,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)
@@ -385,12 +390,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);
@@ -423,10 +422,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;
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
}
diff --git a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp
index cb32c9a..4bbc9d8 100644
--- a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp
+++ b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp
@@ -92,6 +92,8 @@ private slots:
void creating();
void creatingQObject();
void mixTrackingPointerCode();
+ void reentrancyWhileDestructing();
+
void threadStressTest_data();
void threadStressTest();
void validConstructs();
@@ -1770,6 +1772,60 @@ void tst_QSharedPointer::invalidConstructs()
}
}
+namespace QTBUG11730 {
+ struct IB
+ {
+ virtual ~IB() {}
+ };
+
+ struct IA
+ {
+ virtual QSharedPointer<IB> getB() = 0;
+ };
+
+ struct B: public IB
+ {
+ IA *m_a;
+ B(IA *a_a) :m_a(a_a)
+ { }
+ ~B()
+ {
+ QSharedPointer<IB> b = m_a->getB();
+ }
+ };
+
+ struct A: public IA
+ {
+ QSharedPointer<IB> b;
+
+ virtual QSharedPointer<IB> getB()
+ {
+ return b;
+ }
+
+ A()
+ {
+ b = QSharedPointer<IB>(new B(this));
+ }
+
+ ~A()
+ {
+ b.clear();
+ }
+ };
+}
+
+void tst_QSharedPointer::reentrancyWhileDestructing()
+{
+ // this bug is about recursing back into QSharedPointer::clear()
+ // from inside it
+ // that is, the destructor of the object being deleted recurses
+ // into the same QSharedPointer object.
+ // First reported as QTBUG-11730
+ QTBUG11730::A obj;
+}
+
+
QTEST_MAIN(tst_QSharedPointer)
#include "tst_qsharedpointer.moc"