summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
authorJoão Abecasis <joao.abecasis@nokia.com>2011-02-16 18:01:17 (GMT)
committerJoão Abecasis <joao.abecasis@nokia.com>2011-02-16 18:01:17 (GMT)
commit9db05f0b7bf68392dc925d4047aa74dac88b348a (patch)
tree3690ea636187c9af9459ff3bfd4cab3e2af97c57 /src/corelib/kernel
parent0df215e5afc780c1fddd9e410f7ef0814ac1307c (diff)
parent5a1676af979ab75c8939e53e0223ccbea7708de4 (diff)
downloadQt-9db05f0b7bf68392dc925d4047aa74dac88b348a.zip
Qt-9db05f0b7bf68392dc925d4047aa74dac88b348a.tar.gz
Qt-9db05f0b7bf68392dc925d4047aa74dac88b348a.tar.bz2
Merge branch earth-team/master into earth-staging
Conflicts: doc/src/development/qmake-manual.qdoc
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/qeventloop.cpp5
-rw-r--r--src/corelib/kernel/qobject.h8
2 files changed, 9 insertions, 4 deletions
diff --git a/src/corelib/kernel/qeventloop.cpp b/src/corelib/kernel/qeventloop.cpp
index e78f86a..d213b0e 100644
--- a/src/corelib/kernel/qeventloop.cpp
+++ b/src/corelib/kernel/qeventloop.cpp
@@ -175,6 +175,8 @@ bool QEventLoop::processEvents(ProcessEventsFlags flags)
int QEventLoop::exec(ProcessEventsFlags flags)
{
Q_D(QEventLoop);
+ //we need to protect from race condition with QThread::exit
+ QMutexLocker locker(&static_cast<QThreadPrivate *>(QObjectPrivate::get(d->threadData->thread))->mutex);
if (d->threadData->quitNow)
return -1;
@@ -186,6 +188,7 @@ int QEventLoop::exec(ProcessEventsFlags flags)
d->exit = false;
++d->threadData->loopLevel;
d->threadData->eventLoops.push(this);
+ locker.unlock();
// remove posted quit events when entering a new event loop
QCoreApplication *app = QCoreApplication::instance();
@@ -205,6 +208,7 @@ int QEventLoop::exec(ProcessEventsFlags flags)
"reimplement QApplication::notify() and catch all exceptions there.\n");
// copied from below
+ locker.relock();
QEventLoop *eventLoop = d->threadData->eventLoops.pop();
Q_ASSERT_X(eventLoop == this, "QEventLoop::exec()", "internal error");
Q_UNUSED(eventLoop); // --release warning
@@ -216,6 +220,7 @@ int QEventLoop::exec(ProcessEventsFlags flags)
#endif
// copied above
+ locker.relock();
QEventLoop *eventLoop = d->threadData->eventLoops.pop();
Q_ASSERT_X(eventLoop == this, "QEventLoop::exec()", "internal error");
Q_UNUSED(eventLoop); // --release warning
diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h
index 5a7ee2f..0ad73f5 100644
--- a/src/corelib/kernel/qobject.h
+++ b/src/corelib/kernel/qobject.h
@@ -370,18 +370,18 @@ template <class T>
inline T qobject_cast(QObject *object)
{
#if !defined(QT_NO_QOBJECT_CHECK)
- reinterpret_cast<T>(0)->qt_check_for_QOBJECT_macro(*reinterpret_cast<T>(object));
+ reinterpret_cast<T>(object)->qt_check_for_QOBJECT_macro(*reinterpret_cast<T>(object));
#endif
- return static_cast<T>(reinterpret_cast<T>(0)->staticMetaObject.cast(object));
+ return static_cast<T>(reinterpret_cast<T>(object)->staticMetaObject.cast(object));
}
template <class T>
inline T qobject_cast(const QObject *object)
{
#if !defined(QT_NO_QOBJECT_CHECK)
- reinterpret_cast<T>(0)->qt_check_for_QOBJECT_macro(*reinterpret_cast<T>(const_cast<QObject *>(object)));
+ reinterpret_cast<T>(object)->qt_check_for_QOBJECT_macro(*reinterpret_cast<T>(const_cast<QObject *>(object)));
#endif
- return static_cast<T>(reinterpret_cast<T>(0)->staticMetaObject.cast(object));
+ return static_cast<T>(reinterpret_cast<T>(object)->staticMetaObject.cast(object));
}