summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@nokia.com>2010-07-14 06:55:05 (GMT)
committerPaul Olav Tvete <paul.tvete@nokia.com>2010-07-14 06:55:05 (GMT)
commit0832d7209e3aee7055fb39339030ff6842f4117d (patch)
tree75ec174a5492d0ddc52bc2f4dcdef363714a63cb /src/corelib/thread
parentad0d0c4b6f7958b3cde01855b0f3b9c68db5253a (diff)
parentdf28c1203e12c572f795b8d114254a8e5a6619e8 (diff)
downloadQt-0832d7209e3aee7055fb39339030ff6842f4117d.zip
Qt-0832d7209e3aee7055fb39339030ff6842f4117d.tar.gz
Qt-0832d7209e3aee7055fb39339030ff6842f4117d.tar.bz2
Merge remote branch 'qt/4.7' into lighthouse-4.7
Conflicts: src/gui/image/image.pri src/gui/image/qpixmapdatafactory.cpp src/gui/painting/qgraphicssystem.cpp
Diffstat (limited to 'src/corelib/thread')
-rw-r--r--src/corelib/thread/qsemaphore.cpp7
-rw-r--r--src/corelib/thread/qthread_unix.cpp8
2 files changed, 14 insertions, 1 deletions
diff --git a/src/corelib/thread/qsemaphore.cpp b/src/corelib/thread/qsemaphore.cpp
index 9dc828d..8e8a88a 100644
--- a/src/corelib/thread/qsemaphore.cpp
+++ b/src/corelib/thread/qsemaphore.cpp
@@ -44,6 +44,8 @@
#ifndef QT_NO_THREAD
#include "qmutex.h"
#include "qwaitcondition.h"
+#include "qelapsedtimer.h"
+#include "qdatetime.h"
QT_BEGIN_NAMESPACE
@@ -218,8 +220,11 @@ bool QSemaphore::tryAcquire(int n, int timeout)
while (n > d->avail)
d->cond.wait(locker.mutex());
} else {
+ QElapsedTimer timer;
+ timer.start();
while (n > d->avail) {
- if (!d->cond.wait(locker.mutex(), timeout))
+ if (timer.hasExpired(timeout)
+ || !d->cond.wait(locker.mutex(), timeout - timer.elapsed()))
return false;
}
}
diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp
index 47a13d7..16a0a46 100644
--- a/src/corelib/thread/qthread_unix.cpp
+++ b/src/corelib/thread/qthread_unix.cpp
@@ -247,6 +247,14 @@ void *QThreadPrivate::start(void *arg)
data->symbian_thread_handle = RThread();
TThreadId threadId = data->symbian_thread_handle.Id();
data->symbian_thread_handle.Open(threadId);
+ // On symbian, threads other than the main thread are non critical by default
+ // This means a worker thread can crash without crashing the application - to
+ // use this feature, we would need to use RThread::Logon in the main thread
+ // to catch abnormal thread exit and emit the finished signal.
+ // For the sake of cross platform consistency, we set the thread as process critical
+ // - advanced users who want the symbian behaviour can change the critical
+ // attribute of the thread again once the app gains control in run()
+ User::SetCritical(User::EProcessCritical);
#endif
pthread_once(&current_thread_data_once, create_current_thread_data_key);