Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -Naurb ./qt-everywhere-opensource-src-4.8.4/src/corelib/plugin/quuid.cpp ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/plugin/quuid.cpp
- --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/plugin/quuid.cpp 2012-11-23 14:09:55.000000000 +0400
- +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/plugin/quuid.cpp 2013-02-14 19:42:00.000000000 +0400
- @@ -105,6 +105,43 @@
- *dst = Char('}');
- }
- +
- +void _q_uuidToHex(char *&dst, const uint &d1, const ushort &d2, const ushort &d3, const uchar (&d4)[8])
- +{
- + *dst++ = char('{');
- + _q_toHex(dst, d1);
- + *dst++ = char('-');
- + _q_toHex(dst, d2);
- + *dst++ = char('-');
- + _q_toHex(dst, d3);
- + *dst++ = char('-');
- + for (int i = 0; i < 2; i++)
- + _q_toHex(dst, d4[i]);
- + *dst++ = char('-');
- + for (int i = 2; i < 8; i++)
- + _q_toHex(dst, d4[i]);
- + *dst = char('}');
- +}
- +
- +
- +void _q_uuidToHex(ushort *&dst, const uint &d1, const ushort &d2, const ushort &d3, const uchar (&d4)[8])
- +{
- + *dst++ = ushort('{');
- + _q_toHex(dst, d1);
- + *dst++ = ushort('-');
- + _q_toHex(dst, d2);
- + *dst++ = ushort('-');
- + _q_toHex(dst, d3);
- + *dst++ = ushort('-');
- + for (int i = 0; i < 2; i++)
- + _q_toHex(dst, d4[i]);
- + *dst++ = ushort('-');
- + for (int i = 2; i < 8; i++)
- + _q_toHex(dst, d4[i]);
- + *dst = ushort('}');
- +}
- +
- +
- template <class Char>
- bool _q_uuidFromHex(const Char *&src, uint &d1, ushort &d2, ushort &d3, uchar (&d4)[8])
- {
- @@ -130,6 +167,59 @@
- return true;
- }
- +
- +
- +bool _q_uuidFromHex(const char *&src, uint &d1, ushort &d2, ushort &d3, uchar (&d4)[8])
- +{
- + if (*src == char('{'))
- + src++;
- + if (!_q_fromHex(src, d1)
- + || *src++ != char('-')
- + || !_q_fromHex(src, d2)
- + || *src++ != char('-')
- + || !_q_fromHex(src, d3)
- + || *src++ != char('-')
- + || !_q_fromHex(src, d4[0])
- + || !_q_fromHex(src, d4[1])
- + || *src++ != char('-')
- + || !_q_fromHex(src, d4[2])
- + || !_q_fromHex(src, d4[3])
- + || !_q_fromHex(src, d4[4])
- + || !_q_fromHex(src, d4[5])
- + || !_q_fromHex(src, d4[6])
- + || !_q_fromHex(src, d4[7])) {
- + return false;
- + }
- +
- + return true;
- +}
- +
- +
- +bool _q_uuidFromHex(const ushort *&src, uint &d1, ushort &d2, ushort &d3, uchar (&d4)[8])
- +{
- + if (*src == ushort('{'))
- + src++;
- + if (!_q_fromHex(src, d1)
- + || *src++ != ushort('-')
- + || !_q_fromHex(src, d2)
- + || *src++ != ushort('-')
- + || !_q_fromHex(src, d3)
- + || *src++ != ushort('-')
- + || !_q_fromHex(src, d4[0])
- + || !_q_fromHex(src, d4[1])
- + || *src++ != ushort('-')
- + || !_q_fromHex(src, d4[2])
- + || !_q_fromHex(src, d4[3])
- + || !_q_fromHex(src, d4[4])
- + || !_q_fromHex(src, d4[5])
- + || !_q_fromHex(src, d4[6])
- + || !_q_fromHex(src, d4[7])) {
- + return false;
- + }
- +
- + return true;
- +}
- +
- #endif
- /*!
- diff -Naurb ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qatomic.cpp ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qatomic.cpp
- --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qatomic.cpp 2012-11-23 14:09:55.000000000 +0400
- +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qatomic.cpp 2011-06-23 11:45:00.000000000 +0400
- @@ -1,18 +1,17 @@
- /****************************************************************************
- **
- -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
- -** Contact: http://www.qt-project.org/legal
- +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
- +** All rights reserved.
- +** Contact: Nokia Corporation (qt-info@nokia.com)
- **
- ** This file is part of the QtCore module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
- -** Commercial License Usage
- -** Licensees holding valid commercial Qt licenses may use this file in
- -** accordance with the commercial license agreement provided with the
- +** Commercial Usage
- +** Licensees holding valid Qt Commercial licenses may use this file in
- +** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- -** a written agreement between you and Digia. For licensing terms and
- -** conditions see http://qt.digia.com/licensing. For further information
- -** use the contact form at http://qt.digia.com/contact-us.
- +** a written agreement between you and Nokia.
- **
- ** GNU Lesser General Public License Usage
- ** Alternatively, this file may be used under the terms of the GNU Lesser
- @@ -22,8 +21,8 @@
- ** ensure the GNU Lesser General Public License version 2.1 requirements
- ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- **
- -** In addition, as a special exception, Digia gives you certain additional
- -** rights. These rights are described in the Digia Qt LGPL Exception
- +** In addition, as a special exception, Nokia gives you certain additional
- +** rights. These rights are described in the Nokia Qt LGPL Exception
- ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- **
- ** GNU General Public License Usage
- @@ -34,7 +33,8 @@
- ** ensure the GNU General Public License version 3.0 requirements will be
- ** met: http://www.gnu.org/copyleft/gpl.html.
- **
- -**
- +** If you have questions regarding the use of this file, please contact
- +** Nokia at qt-info@nokia.com.
- ** $QT_END_LICENSE$
- **
- ****************************************************************************/
- @@ -48,9 +48,10 @@
- For atomic operations on pointers, see the QAtomicPointer class.
- - An \e atomic operation is a complex operation that completes without interruption.
- - The QAtomicInt class provides atomic reference counting, test-and-set, fetch-and-store,
- - and fetch-and-add for integers.
- + An complex operation that completes without interruption is said
- + to be \e atomic. The QAtomicInt class provides atomic reference
- + counting, test-and-set, fetch-and-store, and fetch-and-add for
- + integers.
- \section1 Non-atomic convenience operators
- @@ -634,8 +635,9 @@
- For atomic operations on integers, see the QAtomicInt class.
- - An \e atomic operation is a complex operation that completes without interruption.
- - The QAtomicPointer class provides atomic test-and-set, fetch-and-store, and fetch-and-add for pointers.
- + An complex operation that completes without interruption is said
- + to be \e atomic. The QAtomicPointer class provides atomic
- + test-and-set, fetch-and-store, and fetch-and-add for pointers.
- \section1 Non-atomic convenience operators
- diff -Naurb ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qatomic.h ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qatomic.h
- --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qatomic.h 2012-11-23 14:09:55.000000000 +0400
- +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qatomic.h 2011-06-23 11:45:00.000000000 +0400
- @@ -1,18 +1,17 @@
- /****************************************************************************
- **
- -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
- -** Contact: http://www.qt-project.org/legal
- +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
- +** All rights reserved.
- +** Contact: Nokia Corporation (qt-info@nokia.com)
- **
- ** This file is part of the QtCore module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
- -** Commercial License Usage
- -** Licensees holding valid commercial Qt licenses may use this file in
- -** accordance with the commercial license agreement provided with the
- +** Commercial Usage
- +** Licensees holding valid Qt Commercial licenses may use this file in
- +** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- -** a written agreement between you and Digia. For licensing terms and
- -** conditions see http://qt.digia.com/licensing. For further information
- -** use the contact form at http://qt.digia.com/contact-us.
- +** a written agreement between you and Nokia.
- **
- ** GNU Lesser General Public License Usage
- ** Alternatively, this file may be used under the terms of the GNU Lesser
- @@ -22,8 +21,8 @@
- ** ensure the GNU Lesser General Public License version 2.1 requirements
- ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- **
- -** In addition, as a special exception, Digia gives you certain additional
- -** rights. These rights are described in the Digia Qt LGPL Exception
- +** In addition, as a special exception, Nokia gives you certain additional
- +** rights. These rights are described in the Nokia Qt LGPL Exception
- ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- **
- ** GNU General Public License Usage
- @@ -34,7 +33,8 @@
- ** ensure the GNU General Public License version 3.0 requirements will be
- ** met: http://www.gnu.org/copyleft/gpl.html.
- **
- -**
- +** If you have questions regarding the use of this file, please contact
- +** Nokia at qt-info@nokia.com.
- ** $QT_END_LICENSE$
- **
- ****************************************************************************/
- diff -Naurb ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qbasicatomic.h ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qbasicatomic.h
- --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qbasicatomic.h 2012-11-23 14:09:55.000000000 +0400
- +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qbasicatomic.h 2011-06-23 11:45:00.000000000 +0400
- @@ -1,18 +1,17 @@
- /****************************************************************************
- **
- -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
- -** Contact: http://www.qt-project.org/legal
- +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
- +** All rights reserved.
- +** Contact: Nokia Corporation (qt-info@nokia.com)
- **
- ** This file is part of the QtCore module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
- -** Commercial License Usage
- -** Licensees holding valid commercial Qt licenses may use this file in
- -** accordance with the commercial license agreement provided with the
- +** Commercial Usage
- +** Licensees holding valid Qt Commercial licenses may use this file in
- +** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- -** a written agreement between you and Digia. For licensing terms and
- -** conditions see http://qt.digia.com/licensing. For further information
- -** use the contact form at http://qt.digia.com/contact-us.
- +** a written agreement between you and Nokia.
- **
- ** GNU Lesser General Public License Usage
- ** Alternatively, this file may be used under the terms of the GNU Lesser
- @@ -22,8 +21,8 @@
- ** ensure the GNU Lesser General Public License version 2.1 requirements
- ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- **
- -** In addition, as a special exception, Digia gives you certain additional
- -** rights. These rights are described in the Digia Qt LGPL Exception
- +** In addition, as a special exception, Nokia gives you certain additional
- +** rights. These rights are described in the Nokia Qt LGPL Exception
- ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- **
- ** GNU General Public License Usage
- @@ -34,7 +33,8 @@
- ** ensure the GNU General Public License version 3.0 requirements will be
- ** met: http://www.gnu.org/copyleft/gpl.html.
- **
- -**
- +** If you have questions regarding the use of this file, please contact
- +** Nokia at qt-info@nokia.com.
- ** $QT_END_LICENSE$
- **
- ****************************************************************************/
- diff -Naurb ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qmutex.cpp ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qmutex.cpp
- --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qmutex.cpp 2012-11-23 14:09:55.000000000 +0400
- +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qmutex.cpp 2011-06-23 11:45:00.000000000 +0400
- @@ -1,18 +1,17 @@
- /****************************************************************************
- **
- -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
- -** Contact: http://www.qt-project.org/legal
- +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
- +** All rights reserved.
- +** Contact: Nokia Corporation (qt-info@nokia.com)
- **
- ** This file is part of the QtCore module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
- -** Commercial License Usage
- -** Licensees holding valid commercial Qt licenses may use this file in
- -** accordance with the commercial license agreement provided with the
- +** Commercial Usage
- +** Licensees holding valid Qt Commercial licenses may use this file in
- +** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- -** a written agreement between you and Digia. For licensing terms and
- -** conditions see http://qt.digia.com/licensing. For further information
- -** use the contact form at http://qt.digia.com/contact-us.
- +** a written agreement between you and Nokia.
- **
- ** GNU Lesser General Public License Usage
- ** Alternatively, this file may be used under the terms of the GNU Lesser
- @@ -22,8 +21,8 @@
- ** ensure the GNU Lesser General Public License version 2.1 requirements
- ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- **
- -** In addition, as a special exception, Digia gives you certain additional
- -** rights. These rights are described in the Digia Qt LGPL Exception
- +** In addition, as a special exception, Nokia gives you certain additional
- +** rights. These rights are described in the Nokia Qt LGPL Exception
- ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- **
- ** GNU General Public License Usage
- @@ -34,18 +33,17 @@
- ** ensure the GNU General Public License version 3.0 requirements will be
- ** met: http://www.gnu.org/copyleft/gpl.html.
- **
- -**
- +** If you have questions regarding the use of this file, please contact
- +** Nokia at qt-info@nokia.com.
- ** $QT_END_LICENSE$
- **
- ****************************************************************************/
- #include "qplatformdefs.h"
- #include "qmutex.h"
- -#include <qdebug.h>
- #ifndef QT_NO_THREAD
- #include "qatomic.h"
- -#include "qelapsedtimer.h"
- #include "qthread.h"
- #include "qmutex_p.h"
- @@ -131,7 +129,7 @@
- \warning Destroying a locked mutex may result in undefined behavior.
- */
- QMutex::~QMutex()
- -{ delete static_cast<QMutexPrivate *>(d); }
- +{ delete d; }
- /*!
- Locks the mutex. If another thread has locked the mutex then this
- @@ -147,7 +145,6 @@
- */
- void QMutex::lock()
- {
- - QMutexPrivate *d = static_cast<QMutexPrivate *>(this->d);
- Qt::HANDLE self;
- if (d->recursive) {
- @@ -158,12 +155,21 @@
- return;
- }
- - bool isLocked = d->contenders.testAndSetAcquire(0, 1);
- + bool isLocked = d->contenders.fetchAndAddAcquire(1) == 0;
- if (!isLocked) {
- +#ifndef QT_NO_DEBUG
- + if (d->owner == self)
- + qWarning("QMutex::lock: Deadlock detected in thread %ld",
- + long(d->owner));
- +#endif
- +
- // didn't get the lock, wait for it
- isLocked = d->wait();
- Q_ASSERT_X(isLocked, "QMutex::lock",
- "Internal error, infinite wait has timed out.");
- +
- + // don't need to wait for the lock anymore
- + d->contenders.deref();
- }
- d->owner = self;
- @@ -172,10 +178,55 @@
- return;
- }
- - bool isLocked = d->contenders.testAndSetAcquire(0, 1);
- +#ifndef QT_NO_DEBUG
- + self = QThread::currentThreadId();
- +#endif
- +
- + bool isLocked = d->contenders == 0 && d->contenders.testAndSetAcquire(0, 1);
- if (!isLocked) {
- - lockInternal();
- + int spinCount = 0;
- + int lastSpinCount = d->lastSpinCount;
- +
- + enum { AdditionalSpins = 20, SpinCountPenalizationDivisor = 4 };
- + const int maximumSpinCount = lastSpinCount + AdditionalSpins;
- +
- + do {
- + if (spinCount++ > maximumSpinCount) {
- + // puts("spinning useless, sleeping");
- + isLocked = d->contenders.fetchAndAddAcquire(1) == 0;
- + if (!isLocked) {
- +#ifndef QT_NO_DEBUG
- + if (d->owner == self)
- + qWarning("QMutex::lock: Deadlock detected in thread %ld",
- + long(d->owner));
- +#endif
- +
- + // didn't get the lock, wait for it
- + isLocked = d->wait();
- + Q_ASSERT_X(isLocked, "QMutex::lock",
- + "Internal error, infinite wait has timed out.");
- +
- + // don't need to wait for the lock anymore
- + d->contenders.deref();
- }
- + // decrease the lastSpinCount since we didn't actually get the lock by spinning
- + spinCount = -d->lastSpinCount / SpinCountPenalizationDivisor;
- + break;
- + }
- +
- + isLocked = d->contenders == 0 && d->contenders.testAndSetAcquire(0, 1);
- + } while (!isLocked);
- +
- + // adjust the last spin lock count
- + lastSpinCount = d->lastSpinCount;
- + d->lastSpinCount = spinCount >= 0
- + ? qMax(lastSpinCount, spinCount)
- + : lastSpinCount + spinCount;
- + }
- +
- +#ifndef QT_NO_DEBUG
- + d->owner = self;
- +#endif
- }
- /*!
- @@ -197,7 +248,6 @@
- */
- bool QMutex::tryLock()
- {
- - QMutexPrivate *d = static_cast<QMutexPrivate *>(this->d);
- Qt::HANDLE self;
- if (d->recursive) {
- @@ -208,7 +258,7 @@
- return true;
- }
- - bool isLocked = d->contenders.testAndSetAcquire(0, 1);
- + bool isLocked = d->contenders == 0 && d->contenders.testAndSetAcquire(0, 1);
- if (!isLocked) {
- // some other thread has the mutex locked, or we tried to
- // recursively lock an non-recursive mutex
- @@ -221,7 +271,19 @@
- return isLocked;
- }
- - return d->contenders.testAndSetAcquire(0, 1);
- +#ifndef QT_NO_DEBUG
- + self = QThread::currentThreadId();
- +#endif
- + bool isLocked = d->contenders == 0 && d->contenders.testAndSetAcquire(0, 1);
- + if (!isLocked) {
- + // some other thread has the mutex locked, or we tried to
- + // recursively lock an non-recursive mutex
- + return isLocked;
- + }
- +#ifndef QT_NO_DEBUG
- + d->owner = self;
- +#endif
- + return isLocked;
- }
- /*! \overload
- @@ -249,7 +311,6 @@
- */
- bool QMutex::tryLock(int timeout)
- {
- - QMutexPrivate *d = static_cast<QMutexPrivate *>(this->d);
- Qt::HANDLE self;
- if (d->recursive) {
- @@ -260,10 +321,13 @@
- return true;
- }
- - bool isLocked = d->contenders.testAndSetAcquire(0, 1);
- + bool isLocked = d->contenders.fetchAndAddAcquire(1) == 0;
- if (!isLocked) {
- // didn't get the lock, wait for it
- isLocked = d->wait(timeout);
- +
- + // don't need to wait for the lock anymore
- + d->contenders.deref();
- if (!isLocked)
- return false;
- }
- @@ -274,9 +338,23 @@
- return true;
- }
- - return (d->contenders.testAndSetAcquire(0, 1)
- +#ifndef QT_NO_DEBUG
- + self = QThread::currentThreadId();
- +#endif
- + bool isLocked = d->contenders.fetchAndAddAcquire(1) == 0;
- + if (!isLocked) {
- // didn't get the lock, wait for it
- - || d->wait(timeout));
- + isLocked = d->wait(timeout);
- +
- + // don't need to wait for the lock anymore
- + d->contenders.deref();
- + if (!isLocked)
- + return false;
- + }
- +#ifndef QT_NO_DEBUG
- + d->owner = self;
- +#endif
- + return true;
- }
- @@ -289,7 +367,9 @@
- */
- void QMutex::unlock()
- {
- - QMutexPrivate *d = static_cast<QMutexPrivate *>(this->d);
- + Q_ASSERT_X(d->owner == QThread::currentThreadId(), "QMutex::unlock()",
- + "A mutex must be unlocked in the same thread that locked it.");
- +
- if (d->recursive) {
- if (!--d->count) {
- d->owner = 0;
- @@ -297,6 +377,9 @@
- d->wakeUp();
- }
- } else {
- +#ifndef QT_NO_DEBUG
- + d->owner = 0;
- +#endif
- if (!d->contenders.testAndSetRelease(1, 0))
- d->wakeUp();
- }
- @@ -424,92 +507,6 @@
- Use the constructor that takes a RecursionMode parameter instead.
- */
- -/*!
- - \internal helper for lockInline()
- - */
- -void QMutex::lockInternal()
- -{
- - QMutexPrivate *d = static_cast<QMutexPrivate *>(this->d);
- -
- - if (QThread::idealThreadCount() == 1) {
- - // don't spin on single cpu machines
- - bool isLocked = d->wait();
- - Q_ASSERT_X(isLocked, "QMutex::lock",
- - "Internal error, infinite wait has timed out.");
- - Q_UNUSED(isLocked);
- - return;
- - }
- -
- - QElapsedTimer elapsedTimer;
- - elapsedTimer.start();
- - do {
- - qint64 spinTime = elapsedTimer.nsecsElapsed();
- - if (spinTime > d->maximumSpinTime) {
- - // didn't get the lock, wait for it, since we're not going to gain anything by spinning more
- - elapsedTimer.start();
- - bool isLocked = d->wait();
- - Q_ASSERT_X(isLocked, "QMutex::lock",
- - "Internal error, infinite wait has timed out.");
- - Q_UNUSED(isLocked);
- -
- - qint64 maximumSpinTime = d->maximumSpinTime;
- - qint64 averageWaitTime = d->averageWaitTime;
- - qint64 actualWaitTime = elapsedTimer.nsecsElapsed();
- - if (actualWaitTime < (QMutexPrivate::MaximumSpinTimeThreshold * 3 / 2)) {
- - // measure the wait times
- - averageWaitTime = d->averageWaitTime = qMin((averageWaitTime + actualWaitTime) / 2, qint64(QMutexPrivate::MaximumSpinTimeThreshold));
- - }
- -
- - // adjust the spin count when spinning does not benefit contention performance
- - if ((spinTime + actualWaitTime) - qint64(QMutexPrivate::MaximumSpinTimeThreshold) >= qint64(QMutexPrivate::MaximumSpinTimeThreshold)) {
- - // long waits, stop spinning
- - d->maximumSpinTime = 0;
- - } else {
- - // allow spinning if wait times decrease, but never spin more than the average wait time (otherwise we may perform worse)
- - d->maximumSpinTime = qBound(qint64(averageWaitTime * 3 / 2), maximumSpinTime / 2, qint64(QMutexPrivate::MaximumSpinTimeThreshold));
- - }
- - return;
- - }
- - // be a good citizen... yielding lets something else run if there is something to run, but may also relieve memory pressure if not
- - QThread::yieldCurrentThread();
- - } while (d->contenders != 0 || !d->contenders.testAndSetAcquire(0, 1));
- -
- - // spinning is working, do not change the spin time (unless we are using much less time than allowed to spin)
- - qint64 maximumSpinTime = d->maximumSpinTime;
- - qint64 spinTime = elapsedTimer.nsecsElapsed();
- - if (spinTime < maximumSpinTime / 2) {
- - // we are using much less time than we need, adjust the limit
- - d->maximumSpinTime = qBound(qint64(d->averageWaitTime * 3 / 2), maximumSpinTime / 2, qint64(QMutexPrivate::MaximumSpinTimeThreshold));
- - }
- -}
- -
- -/*!
- - \internal
- -*/
- -void QMutex::unlockInternal()
- -{
- - static_cast<QMutexPrivate *>(d)->wakeUp();
- -}
- -
- -/*!
- - \fn QMutex::lockInline()
- - \internal
- - inline version of QMutex::lock()
- -*/
- -
- -/*!
- - \fn QMutex::unlockInline()
- - \internal
- - inline version of QMutex::unlock()
- -*/
- -
- -/*!
- - \fn QMutex::tryLockInline()
- - \internal
- - inline version of QMutex::tryLock()
- -*/
- -
- -
- QT_END_NAMESPACE
- #endif // QT_NO_THREAD
- diff -Naurb ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qmutex.h ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qmutex.h
- --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qmutex.h 2012-11-23 14:09:55.000000000 +0400
- +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qmutex.h 2013-02-14 19:57:00.000000000 +0400
- @@ -1,18 +1,17 @@
- /****************************************************************************
- **
- -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
- -** Contact: http://www.qt-project.org/legal
- +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
- +** All rights reserved.
- +** Contact: Nokia Corporation (qt-info@nokia.com)
- **
- ** This file is part of the QtCore module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
- -** Commercial License Usage
- -** Licensees holding valid commercial Qt licenses may use this file in
- -** accordance with the commercial license agreement provided with the
- +** Commercial Usage
- +** Licensees holding valid Qt Commercial licenses may use this file in
- +** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- -** a written agreement between you and Digia. For licensing terms and
- -** conditions see http://qt.digia.com/licensing. For further information
- -** use the contact form at http://qt.digia.com/contact-us.
- +** a written agreement between you and Nokia.
- **
- ** GNU Lesser General Public License Usage
- ** Alternatively, this file may be used under the terms of the GNU Lesser
- @@ -22,8 +21,8 @@
- ** ensure the GNU Lesser General Public License version 2.1 requirements
- ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- **
- -** In addition, as a special exception, Digia gives you certain additional
- -** rights. These rights are described in the Digia Qt LGPL Exception
- +** In addition, as a special exception, Nokia gives you certain additional
- +** rights. These rights are described in the Nokia Qt LGPL Exception
- ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- **
- ** GNU General Public License Usage
- @@ -34,7 +33,8 @@
- ** ensure the GNU General Public License version 3.0 requirements will be
- ** met: http://www.gnu.org/copyleft/gpl.html.
- **
- -**
- +** If you have questions regarding the use of this file, please contact
- +** Nokia at qt-info@nokia.com.
- ** $QT_END_LICENSE$
- **
- ****************************************************************************/
- @@ -43,7 +43,6 @@
- #define QMUTEX_H
- #include <QtCore/qglobal.h>
- -#include <QtCore/qatomic.h>
- #include <new>
- QT_BEGIN_HEADER
- @@ -54,8 +53,7 @@
- #ifndef QT_NO_THREAD
- -class QAtomicInt;
- -class QMutexData;
- +class QMutexPrivate;
- class Q_CORE_EXPORT QMutex
- {
- @@ -68,12 +66,12 @@
- explicit QMutex(RecursionMode mode = NonRecursive);
- ~QMutex();
- - void lock(); //### Qt5: make inline;
- - inline void lockInline();
- - bool tryLock(); //### Qt5: make inline;
- + void lock();
- + bool tryLock();
- bool tryLock(int timeout);
- + void unlock();
- + inline void lockInline();
- inline bool tryLockInline();
- - void unlock(); //### Qt5: make inline;
- inline void unlockInline();
- #if defined(QT3_SUPPORT)
- @@ -91,34 +89,35 @@
- #endif
- private:
- - void lockInternal();
- - void unlockInternal();
- Q_DISABLE_COPY(QMutex)
- - QMutexData *d;
- + QMutexPrivate *d;
- };
- +inline void QMutex::unlockInline() { unlock(); }
- +inline bool QMutex::tryLockInline() { return tryLock(); }
- +inline void QMutex::lockInline() { lock(); }
- +
- +
- class Q_CORE_EXPORT QMutexLocker
- {
- public:
- inline explicit QMutexLocker(QMutex *m)
- + : val(reinterpret_cast<quintptr>(m))
- {
- - Q_ASSERT_X((reinterpret_cast<quintptr>(m) & quintptr(1u)) == quintptr(0),
- + Q_ASSERT_X((val & quintptr(1u)) == quintptr(0),
- "QMutexLocker", "QMutex pointer is misaligned");
- - if (m) {
- - m->lockInline();
- - val = reinterpret_cast<quintptr>(m) | quintptr(1u);
- - } else {
- - val = 0;
- - }
- + relock();
- }
- inline ~QMutexLocker() { unlock(); }
- inline void unlock()
- {
- + if (val) {
- if ((val & quintptr(1u)) == quintptr(1u)) {
- val &= ~quintptr(1u);
- - mutex()->unlockInline();
- + mutex()->unlock();
- + }
- }
- }
- @@ -126,7 +125,7 @@
- {
- if (val) {
- if ((val & quintptr(1u)) == quintptr(0u)) {
- - mutex()->lockInline();
- + mutex()->lock();
- val |= quintptr(1u);
- }
- }
- @@ -152,53 +151,6 @@
- quintptr val;
- };
- -class QMutexData
- -{
- - public:
- - QAtomicInt contenders;
- - const uint recursive : 1;
- - uint reserved : 31;
- - protected:
- - QMutexData(QMutex::RecursionMode mode);
- - ~QMutexData();
- -};
- -
- -#ifdef QT_NO_DEBUG
- -inline void QMutex::unlockInline()
- -{
- - if (d->recursive) {
- - unlock();
- - } else if (!d->contenders.testAndSetRelease(1, 0)) {
- - unlockInternal();
- - }
- -}
- -
- -inline bool QMutex::tryLockInline()
- -{
- - if (d->recursive) {
- - return tryLock();
- - } else {
- - return d->contenders.testAndSetAcquire(0, 1);
- - }
- -}
- -
- -inline void QMutex::lockInline()
- -{
- - if (d->recursive) {
- - lock();
- - } else if(!tryLockInline()) {
- - lockInternal();
- - }
- -}
- -#else // QT_NO_DEBUG
- -//in debug we do not use inline calls in order to allow debugging tools
- -// to hook the mutex locking functions.
- -inline void QMutex::unlockInline() { unlock(); }
- -inline bool QMutex::tryLockInline() { return tryLock(); }
- -inline void QMutex::lockInline() { lock(); }
- -#endif // QT_NO_DEBUG
- -
- -
- #else // QT_NO_THREAD
- @@ -211,16 +163,18 @@
- inline ~QMutex() {}
- static inline void lock() {}
- - static inline void lockInline() {}
- - static inline bool tryLock(int timeout = 0) { Q_UNUSED(timeout); return true; }
- - static inline bool tryLockInline() { return true; }
- - static inline void unlock() {}
- - static inline void unlockInline() {}
- + static inline bool tryLock() { return true; }
- + static inline bool tryLock(int timeout) { Q_UNUSED(timeout); return true; }
- + static void unlock() {}
- #if defined(QT3_SUPPORT)
- static inline QT3_SUPPORT bool locked() { return false; }
- #endif
- + inline void lockInline();
- + inline bool tryLockInline();
- + inline void unlockInline();
- +
- private:
- Q_DISABLE_COPY(QMutex)
- };
- @@ -239,6 +193,7 @@
- Q_DISABLE_COPY(QMutexLocker)
- };
- +
- #endif // QT_NO_THREAD
- QT_END_NAMESPACE
- diff -Naurb ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qmutex_p.h ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qmutex_p.h
- --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qmutex_p.h 2012-11-23 14:09:55.000000000 +0400
- +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qmutex_p.h 2011-06-23 11:45:00.000000000 +0400
- @@ -1,18 +1,17 @@
- /****************************************************************************
- **
- -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
- -** Contact: http://www.qt-project.org/legal
- +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
- +** All rights reserved.
- +** Contact: Nokia Corporation (qt-info@nokia.com)
- **
- ** This file is part of the QtCore module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
- -** Commercial License Usage
- -** Licensees holding valid commercial Qt licenses may use this file in
- -** accordance with the commercial license agreement provided with the
- +** Commercial Usage
- +** Licensees holding valid Qt Commercial licenses may use this file in
- +** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- -** a written agreement between you and Digia. For licensing terms and
- -** conditions see http://qt.digia.com/licensing. For further information
- -** use the contact form at http://qt.digia.com/contact-us.
- +** a written agreement between you and Nokia.
- **
- ** GNU Lesser General Public License Usage
- ** Alternatively, this file may be used under the terms of the GNU Lesser
- @@ -22,8 +21,8 @@
- ** ensure the GNU Lesser General Public License version 2.1 requirements
- ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- **
- -** In addition, as a special exception, Digia gives you certain additional
- -** rights. These rights are described in the Digia Qt LGPL Exception
- +** In addition, as a special exception, Nokia gives you certain additional
- +** rights. These rights are described in the Nokia Qt LGPL Exception
- ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- **
- ** GNU General Public License Usage
- @@ -34,7 +33,8 @@
- ** ensure the GNU General Public License version 3.0 requirements will be
- ** met: http://www.gnu.org/copyleft/gpl.html.
- **
- -**
- +** If you have questions regarding the use of this file, please contact
- +** Nokia at qt-info@nokia.com.
- ** $QT_END_LICENSE$
- **
- ****************************************************************************/
- @@ -56,46 +56,33 @@
- #include <QtCore/qglobal.h>
- #include <QtCore/qnamespace.h>
- -#include <QtCore/qmutex.h>
- -
- -#if defined(Q_OS_SYMBIAN)
- -# include <e32std.h>
- -#endif
- QT_BEGIN_NAMESPACE
- -class QMutexPrivate : public QMutexData {
- +class QMutexPrivate {
- public:
- QMutexPrivate(QMutex::RecursionMode mode);
- ~QMutexPrivate();
- + ulong self();
- bool wait(int timeout = -1);
- void wakeUp();
- - // 1ms = 1000000ns
- - enum { MaximumSpinTimeThreshold = 1000000 };
- - volatile qint64 maximumSpinTime;
- - volatile qint64 averageWaitTime;
- + const bool recursive;
- + QAtomicInt contenders;
- + volatile int lastSpinCount;
- Qt::HANDLE owner;
- uint count;
- -#if defined(Q_OS_UNIX) && !defined(Q_OS_LINUX) && !defined(Q_OS_SYMBIAN)
- +#if defined(Q_OS_UNIX)
- volatile bool wakeup;
- pthread_mutex_t mutex;
- pthread_cond_t cond;
- #elif defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
- HANDLE event;
- -#elif defined(Q_OS_SYMBIAN)
- - RSemaphore lock;
- #endif
- };
- -inline QMutexData::QMutexData(QMutex::RecursionMode mode)
- - : recursive(mode == QMutex::Recursive)
- -{}
- -
- -inline QMutexData::~QMutexData() {}
- -
- QT_END_NAMESPACE
- #endif // QMUTEX_P_H
- diff -Naurb ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qmutexpool.cpp ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qmutexpool.cpp
- --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qmutexpool.cpp 2012-11-23 14:09:55.000000000 +0400
- +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qmutexpool.cpp 2011-06-23 11:45:00.000000000 +0400
- @@ -1,18 +1,17 @@
- /****************************************************************************
- **
- -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
- -** Contact: http://www.qt-project.org/legal
- +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
- +** All rights reserved.
- +** Contact: Nokia Corporation (qt-info@nokia.com)
- **
- ** This file is part of the QtCore module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
- -** Commercial License Usage
- -** Licensees holding valid commercial Qt licenses may use this file in
- -** accordance with the commercial license agreement provided with the
- +** Commercial Usage
- +** Licensees holding valid Qt Commercial licenses may use this file in
- +** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- -** a written agreement between you and Digia. For licensing terms and
- -** conditions see http://qt.digia.com/licensing. For further information
- -** use the contact form at http://qt.digia.com/contact-us.
- +** a written agreement between you and Nokia.
- **
- ** GNU Lesser General Public License Usage
- ** Alternatively, this file may be used under the terms of the GNU Lesser
- @@ -22,8 +21,8 @@
- ** ensure the GNU Lesser General Public License version 2.1 requirements
- ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- **
- -** In addition, as a special exception, Digia gives you certain additional
- -** rights. These rights are described in the Digia Qt LGPL Exception
- +** In addition, as a special exception, Nokia gives you certain additional
- +** rights. These rights are described in the Nokia Qt LGPL Exception
- ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- **
- ** GNU General Public License Usage
- @@ -34,7 +33,8 @@
- ** ensure the GNU General Public License version 3.0 requirements will be
- ** met: http://www.gnu.org/copyleft/gpl.html.
- **
- -**
- +** If you have questions regarding the use of this file, please contact
- +** Nokia at qt-info@nokia.com.
- ** $QT_END_LICENSE$
- **
- ****************************************************************************/
- @@ -46,7 +46,7 @@
- QT_BEGIN_NAMESPACE
- -// qt_global_mutexpool is here for backwards compatibility only,
- +// qt_global_mutexpool is here for backwards compatability only,
- // use QMutexpool::instance() in new clode.
- Q_CORE_EXPORT QMutexPool *qt_global_mutexpool = 0;
- Q_GLOBAL_STATIC_WITH_ARGS(QMutexPool, globalMutexPool, (QMutex::Recursive))
- @@ -124,20 +124,21 @@
- }
- /*!
- - \fn QMutexPool::get(const void *address)
- Returns a QMutex from the pool. QMutexPool uses the value \a address
- to determine which mutex is returned from the pool.
- */
- -
- -/*! \internal
- - create the mutex for the given index
- - */
- -QMutex *QMutexPool::createMutex(int index)
- +QMutex *QMutexPool::get(const void *address)
- {
- + Q_ASSERT_X(address != 0, "QMutexPool::get()", "'address' argument cannot be zero");
- + int index = int((quintptr(address) >> (sizeof(address) >> 1)) % mutexes.count());
- +
- + if (!mutexes[index]) {
- // mutex not created, create one
- QMutex *newMutex = new QMutex(recursionMode);
- if (!mutexes[index].testAndSetOrdered(0, newMutex))
- delete newMutex;
- + }
- +
- return mutexes[index];
- }
- diff -Naurb ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qmutexpool_p.h ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qmutexpool_p.h
- --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qmutexpool_p.h 2012-11-23 14:09:55.000000000 +0400
- +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qmutexpool_p.h 2011-06-23 11:45:00.000000000 +0400
- @@ -1,18 +1,17 @@
- /****************************************************************************
- **
- -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
- -** Contact: http://www.qt-project.org/legal
- +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
- +** All rights reserved.
- +** Contact: Nokia Corporation (qt-info@nokia.com)
- **
- ** This file is part of the QtCore module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
- -** Commercial License Usage
- -** Licensees holding valid commercial Qt licenses may use this file in
- -** accordance with the commercial license agreement provided with the
- +** Commercial Usage
- +** Licensees holding valid Qt Commercial licenses may use this file in
- +** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- -** a written agreement between you and Digia. For licensing terms and
- -** conditions see http://qt.digia.com/licensing. For further information
- -** use the contact form at http://qt.digia.com/contact-us.
- +** a written agreement between you and Nokia.
- **
- ** GNU Lesser General Public License Usage
- ** Alternatively, this file may be used under the terms of the GNU Lesser
- @@ -22,8 +21,8 @@
- ** ensure the GNU Lesser General Public License version 2.1 requirements
- ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- **
- -** In addition, as a special exception, Digia gives you certain additional
- -** rights. These rights are described in the Digia Qt LGPL Exception
- +** In addition, as a special exception, Nokia gives you certain additional
- +** rights. These rights are described in the Nokia Qt LGPL Exception
- ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- **
- ** GNU General Public License Usage
- @@ -34,7 +33,8 @@
- ** ensure the GNU General Public License version 3.0 requirements will be
- ** met: http://www.gnu.org/copyleft/gpl.html.
- **
- -**
- +** If you have questions regarding the use of this file, please contact
- +** Nokia at qt-info@nokia.com.
- ** $QT_END_LICENSE$
- **
- ****************************************************************************/
- @@ -67,19 +67,11 @@
- explicit QMutexPool(QMutex::RecursionMode recursionMode = QMutex::NonRecursive, int size = 131);
- ~QMutexPool();
- - inline QMutex *get(const void *address) {
- - int index = uint(quintptr(address)) % mutexes.count();
- - QMutex *m = mutexes[index];
- - if (m)
- - return m;
- - else
- - return createMutex(index);
- - }
- + QMutex *get(const void *address);
- static QMutexPool *instance();
- static QMutex *globalInstanceGet(const void *address);
- private:
- - QMutex *createMutex(int index);
- QVarLengthArray<QAtomicPointer<QMutex>, 131> mutexes;
- QMutex::RecursionMode recursionMode;
- };
- diff -Naurb ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qmutex_symbian.cpp ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qmutex_symbian.cpp
- --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qmutex_symbian.cpp 2012-11-23 14:09:55.000000000 +0400
- +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qmutex_symbian.cpp 1970-01-01 03:00:00.000000000 +0300
- @@ -1,101 +0,0 @@
- -/****************************************************************************
- -**
- -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
- -** Contact: http://www.qt-project.org/legal
- -**
- -** This file is part of the QtCore module of the Qt Toolkit.
- -**
- -** $QT_BEGIN_LICENSE:LGPL$
- -** Commercial License Usage
- -** Licensees holding valid commercial Qt licenses may use this file in
- -** accordance with the commercial license agreement provided with the
- -** Software or, alternatively, in accordance with the terms contained in
- -** a written agreement between you and Digia. For licensing terms and
- -** conditions see http://qt.digia.com/licensing. For further information
- -** use the contact form at http://qt.digia.com/contact-us.
- -**
- -** GNU Lesser General Public License Usage
- -** Alternatively, this file may be used under the terms of the GNU Lesser
- -** General Public License version 2.1 as published by the Free Software
- -** Foundation and appearing in the file LICENSE.LGPL included in the
- -** packaging of this file. Please review the following information to
- -** ensure the GNU Lesser General Public License version 2.1 requirements
- -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- -**
- -** In addition, as a special exception, Digia gives you certain additional
- -** rights. These rights are described in the Digia Qt LGPL Exception
- -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- -**
- -** GNU General Public License Usage
- -** Alternatively, this file may be used under the terms of the GNU
- -** General Public License version 3.0 as published by the Free Software
- -** Foundation and appearing in the file LICENSE.GPL included in the
- -** packaging of this file. Please review the following information to
- -** ensure the GNU General Public License version 3.0 requirements will be
- -** met: http://www.gnu.org/copyleft/gpl.html.
- -**
- -**
- -** $QT_END_LICENSE$
- -**
- -****************************************************************************/
- -
- -#include "qplatformdefs.h"
- -#include "qmutex.h"
- -
- -#ifndef QT_NO_THREAD
- -#include "qatomic.h"
- -#include "qelapsedtimer.h"
- -#include "qthread.h"
- -#include "qmutex_p.h"
- -
- -QT_BEGIN_NAMESPACE
- -
- -
- -QMutexPrivate::QMutexPrivate(QMutex::RecursionMode mode)
- - : QMutexData(mode), maximumSpinTime(MaximumSpinTimeThreshold), averageWaitTime(0), owner(0), count(0)
- -{
- - int r = lock.CreateLocal(0);
- - if (r != KErrNone)
- - qWarning("QMutex: failed to create lock, error %d", r);
- - qt_symbian_throwIfError(r);
- -}
- -
- -QMutexPrivate::~QMutexPrivate()
- -{
- - lock.Close();
- -}
- -
- -bool QMutexPrivate::wait(int timeout)
- -{
- - if (contenders.fetchAndAddAcquire(1) == 0) {
- - // lock acquired without waiting
- - return true;
- - }
- - int r = KErrTimedOut;
- - if (timeout < 0) {
- - lock.Wait();
- - r = KErrNone;
- - } else {
- - // Symbian lock waits are specified in microseconds.
- - // The wait is therefore chunked.
- - // KErrNone indicates success, KErrGeneral and KErrArgument are real fails, anything else is a timeout
- - do {
- - int waitTime = qMin(KMaxTInt / 1000, timeout);
- - timeout -= waitTime;
- - // Symbian undocumented feature - 0us means no timeout! Use a minimum of 1
- - r = lock.Wait(qMax(1, waitTime * 1000));
- - } while (r != KErrNone && r != KErrGeneral && r != KErrArgument && timeout > 0);
- - }
- - bool returnValue = (r == KErrNone);
- - contenders.deref();
- - return returnValue;
- -}
- -
- -void QMutexPrivate::wakeUp()
- -{
- - lock.Signal();
- -}
- -
- -QT_END_NAMESPACE
- -
- -#endif // QT_NO_THREAD
- diff -Naurb ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qmutex_unix.cpp ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qmutex_unix.cpp
- --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qmutex_unix.cpp 2012-11-23 14:09:55.000000000 +0400
- +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qmutex_unix.cpp 2011-06-23 11:45:00.000000000 +0400
- @@ -1,18 +1,17 @@
- /****************************************************************************
- **
- -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
- -** Contact: http://www.qt-project.org/legal
- +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
- +** All rights reserved.
- +** Contact: Nokia Corporation (qt-info@nokia.com)
- **
- ** This file is part of the QtCore module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
- -** Commercial License Usage
- -** Licensees holding valid commercial Qt licenses may use this file in
- -** accordance with the commercial license agreement provided with the
- +** Commercial Usage
- +** Licensees holding valid Qt Commercial licenses may use this file in
- +** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- -** a written agreement between you and Digia. For licensing terms and
- -** conditions see http://qt.digia.com/licensing. For further information
- -** use the contact form at http://qt.digia.com/contact-us.
- +** a written agreement between you and Nokia.
- **
- ** GNU Lesser General Public License Usage
- ** Alternatively, this file may be used under the terms of the GNU Lesser
- @@ -22,8 +21,8 @@
- ** ensure the GNU Lesser General Public License version 2.1 requirements
- ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- **
- -** In addition, as a special exception, Digia gives you certain additional
- -** rights. These rights are described in the Digia Qt LGPL Exception
- +** In addition, as a special exception, Nokia gives you certain additional
- +** rights. These rights are described in the Nokia Qt LGPL Exception
- ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- **
- ** GNU General Public License Usage
- @@ -34,7 +33,8 @@
- ** ensure the GNU General Public License version 3.0 requirements will be
- ** met: http://www.gnu.org/copyleft/gpl.html.
- **
- -**
- +** If you have questions regarding the use of this file, please contact
- +** Nokia at qt-info@nokia.com.
- ** $QT_END_LICENSE$
- **
- ****************************************************************************/
- @@ -53,97 +53,30 @@
- #undef wakeup
- #endif
- -#if defined(Q_OS_MAC)
- -# include <mach/mach.h>
- -# include <mach/task.h>
- -#elif defined(Q_OS_LINUX)
- -# include <linux/futex.h>
- -# include <sys/syscall.h>
- -# include <unistd.h>
- -# include <QtCore/qelapsedtimer.h>
- -#endif
- -
- QT_BEGIN_NAMESPACE
- -#if !defined(Q_OS_LINUX)
- static void report_error(int code, const char *where, const char *what)
- {
- if (code != 0)
- qWarning("%s: %s failure: %s", where, what, qPrintable(qt_error_string(code)));
- }
- -#endif
- QMutexPrivate::QMutexPrivate(QMutex::RecursionMode mode)
- - : QMutexData(mode), maximumSpinTime(MaximumSpinTimeThreshold), averageWaitTime(0), owner(0), count(0)
- + : recursive(mode == QMutex::Recursive), contenders(0), lastSpinCount(0), owner(0), count(0), wakeup(false)
- {
- -#if !defined(Q_OS_LINUX)
- - wakeup = false;
- report_error(pthread_mutex_init(&mutex, NULL), "QMutex", "mutex init");
- report_error(pthread_cond_init(&cond, NULL), "QMutex", "cv init");
- -#endif
- }
- QMutexPrivate::~QMutexPrivate()
- {
- -#if !defined(Q_OS_LINUX)
- report_error(pthread_cond_destroy(&cond), "QMutex", "cv destroy");
- report_error(pthread_mutex_destroy(&mutex), "QMutex", "mutex destroy");
- -#endif
- -}
- -
- -#if defined(Q_OS_LINUX)
- -
- -static inline int _q_futex(volatile int *addr, int op, int val, const struct timespec *timeout, int *addr2, int val2)
- -{
- - return syscall(SYS_futex, addr, op, val, timeout, addr2, val2);
- }
- bool QMutexPrivate::wait(int timeout)
- {
- - struct timespec ts, *pts = 0;
- - QElapsedTimer timer;
- - if (timeout >= 0) {
- - ts.tv_nsec = ((timeout % 1000) * 1000) * 1000;
- - ts.tv_sec = (timeout / 1000);
- - pts = &ts;
- - timer.start();
- - }
- - while (contenders.fetchAndStoreAcquire(2) > 0) {
- - int r = _q_futex(&contenders._q_value, FUTEX_WAIT, 2, pts, 0, 0);
- - if (r != 0 && errno == ETIMEDOUT)
- - return false;
- -
- - if (pts) {
- - // recalculate the timeout
- - qint64 xtimeout = timeout * 1000 * 1000;
- - xtimeout -= timer.nsecsElapsed();
- - if (xtimeout < 0) {
- - // timer expired after we returned
- - return false;
- - }
- -
- - ts.tv_sec = xtimeout / Q_INT64_C(1000) / 1000 / 1000;
- - ts.tv_nsec = xtimeout % (Q_INT64_C(1000) * 1000 * 1000);
- - }
- - }
- - return true;
- -}
- -
- -void QMutexPrivate::wakeUp()
- -{
- - (void) contenders.fetchAndStoreRelease(0);
- - (void) _q_futex(&contenders._q_value, FUTEX_WAKE, 1, 0, 0, 0);
- -}
- -
- -#else // !Q_OS_LINUX
- -
- -bool QMutexPrivate::wait(int timeout)
- -{
- - if (contenders.fetchAndAddAcquire(1) == 0) {
- - // lock acquired without waiting
- - return true;
- - }
- report_error(pthread_mutex_lock(&mutex), "QMutex::lock", "mutex lock");
- int errorCode = 0;
- while (!wakeup) {
- @@ -171,7 +104,6 @@
- }
- wakeup = false;
- report_error(pthread_mutex_unlock(&mutex), "QMutex::lock", "mutex unlock");
- - contenders.deref();
- return errorCode == 0;
- }
- @@ -183,8 +115,6 @@
- report_error(pthread_mutex_unlock(&mutex), "QMutex::unlock", "mutex unlock");
- }
- -#endif // !Q_OS_LINUX
- -
- QT_END_NAMESPACE
- #endif // QT_NO_THREAD
- diff -Naurb ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qmutex_win.cpp ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qmutex_win.cpp
- --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qmutex_win.cpp 2012-11-23 14:09:55.000000000 +0400
- +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qmutex_win.cpp 2011-06-23 11:45:00.000000000 +0400
- @@ -1,18 +1,17 @@
- /****************************************************************************
- **
- -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
- -** Contact: http://www.qt-project.org/legal
- +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
- +** All rights reserved.
- +** Contact: Nokia Corporation (qt-info@nokia.com)
- **
- ** This file is part of the QtCore module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
- -** Commercial License Usage
- -** Licensees holding valid commercial Qt licenses may use this file in
- -** accordance with the commercial license agreement provided with the
- +** Commercial Usage
- +** Licensees holding valid Qt Commercial licenses may use this file in
- +** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- -** a written agreement between you and Digia. For licensing terms and
- -** conditions see http://qt.digia.com/licensing. For further information
- -** use the contact form at http://qt.digia.com/contact-us.
- +** a written agreement between you and Nokia.
- **
- ** GNU Lesser General Public License Usage
- ** Alternatively, this file may be used under the terms of the GNU Lesser
- @@ -22,8 +21,8 @@
- ** ensure the GNU Lesser General Public License version 2.1 requirements
- ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- **
- -** In addition, as a special exception, Digia gives you certain additional
- -** rights. These rights are described in the Digia Qt LGPL Exception
- +** In addition, as a special exception, Nokia gives you certain additional
- +** rights. These rights are described in the Nokia Qt LGPL Exception
- ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- **
- ** GNU General Public License Usage
- @@ -34,7 +33,8 @@
- ** ensure the GNU General Public License version 3.0 requirements will be
- ** met: http://www.gnu.org/copyleft/gpl.html.
- **
- -**
- +** If you have questions regarding the use of this file, please contact
- +** Nokia at qt-info@nokia.com.
- ** $QT_END_LICENSE$
- **
- ****************************************************************************/
- @@ -48,7 +48,7 @@
- QT_BEGIN_NAMESPACE
- QMutexPrivate::QMutexPrivate(QMutex::RecursionMode mode)
- - : QMutexData(mode), maximumSpinTime(MaximumSpinTimeThreshold), averageWaitTime(0), owner(0), count(0)
- + : recursive(mode == QMutex::Recursive), contenders(0), lastSpinCount(0), owner(0), count(0)
- {
- event = CreateEvent(0, FALSE, FALSE, 0);
- if (!event)
- @@ -60,13 +60,7 @@
- bool QMutexPrivate::wait(int timeout)
- {
- - if (contenders.fetchAndAddAcquire(1) == 0) {
- - // lock acquired without waiting
- - return true;
- - }
- - bool returnValue = (WaitForSingleObject(event, timeout < 0 ? INFINITE : timeout) == WAIT_OBJECT_0);
- - contenders.deref();
- - return returnValue;
- + return WaitForSingleObject(event, timeout < 0 ? INFINITE : timeout) == WAIT_OBJECT_0;
- }
- void QMutexPrivate::wakeUp()
- diff -Naurb ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qorderedmutexlocker_p.h ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qorderedmutexlocker_p.h
- --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qorderedmutexlocker_p.h 2012-11-23 14:09:55.000000000 +0400
- +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qorderedmutexlocker_p.h 2011-06-23 11:45:00.000000000 +0400
- @@ -1,18 +1,17 @@
- /****************************************************************************
- **
- -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
- -** Contact: http://www.qt-project.org/legal
- +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
- +** All rights reserved.
- +** Contact: Nokia Corporation (qt-info@nokia.com)
- **
- ** This file is part of the QtCore module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
- -** Commercial License Usage
- -** Licensees holding valid commercial Qt licenses may use this file in
- -** accordance with the commercial license agreement provided with the
- +** Commercial Usage
- +** Licensees holding valid Qt Commercial licenses may use this file in
- +** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- -** a written agreement between you and Digia. For licensing terms and
- -** conditions see http://qt.digia.com/licensing. For further information
- -** use the contact form at http://qt.digia.com/contact-us.
- +** a written agreement between you and Nokia.
- **
- ** GNU Lesser General Public License Usage
- ** Alternatively, this file may be used under the terms of the GNU Lesser
- @@ -22,8 +21,8 @@
- ** ensure the GNU Lesser General Public License version 2.1 requirements
- ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- **
- -** In addition, as a special exception, Digia gives you certain additional
- -** rights. These rights are described in the Digia Qt LGPL Exception
- +** In addition, as a special exception, Nokia gives you certain additional
- +** rights. These rights are described in the Nokia Qt LGPL Exception
- ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- **
- ** GNU General Public License Usage
- @@ -34,7 +33,8 @@
- ** ensure the GNU General Public License version 3.0 requirements will be
- ** met: http://www.gnu.org/copyleft/gpl.html.
- **
- -**
- +** If you have questions regarding the use of this file, please contact
- +** Nokia at qt-info@nokia.com.
- ** $QT_END_LICENSE$
- **
- ****************************************************************************/
- @@ -55,7 +55,7 @@
- QT_BEGIN_NAMESPACE
- -#include <QtCore/qmutex.h>
- +class QMutex;
- /*
- Locks 2 mutexes in a defined order, avoiding a recursive lock if
- @@ -79,8 +79,8 @@
- void relock()
- {
- if (!locked) {
- - if (mtx1) mtx1->lockInline();
- - if (mtx2) mtx2->lockInline();
- + if (mtx1) mtx1->lock();
- + if (mtx2) mtx2->lock();
- locked = true;
- }
- }
- @@ -88,8 +88,8 @@
- void unlock()
- {
- if (locked) {
- - if (mtx1) mtx1->unlockInline();
- - if (mtx2) mtx2->unlockInline();
- + if (mtx1) mtx1->unlock();
- + if (mtx2) mtx2->unlock();
- locked = false;
- }
- }
- @@ -100,14 +100,12 @@
- if (mtx1 == mtx2)
- return false;
- if (mtx1 < mtx2) {
- - mtx2->lockInline();
- + mtx2->lock();
- return true;
- }
- - if (!mtx2->tryLockInline()) {
- mtx1->unlock();
- mtx2->lock();
- mtx1->lock();
- - }
- return true;
- }
- diff -Naurb ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qreadwritelock.cpp ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qreadwritelock.cpp
- --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qreadwritelock.cpp 2012-11-23 14:09:55.000000000 +0400
- +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qreadwritelock.cpp 2011-06-23 11:45:00.000000000 +0400
- @@ -1,18 +1,17 @@
- /****************************************************************************
- **
- -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
- -** Contact: http://www.qt-project.org/legal
- +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
- +** All rights reserved.
- +** Contact: Nokia Corporation (qt-info@nokia.com)
- **
- ** This file is part of the QtCore module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
- -** Commercial License Usage
- -** Licensees holding valid commercial Qt licenses may use this file in
- -** accordance with the commercial license agreement provided with the
- +** Commercial Usage
- +** Licensees holding valid Qt Commercial licenses may use this file in
- +** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- -** a written agreement between you and Digia. For licensing terms and
- -** conditions see http://qt.digia.com/licensing. For further information
- -** use the contact form at http://qt.digia.com/contact-us.
- +** a written agreement between you and Nokia.
- **
- ** GNU Lesser General Public License Usage
- ** Alternatively, this file may be used under the terms of the GNU Lesser
- @@ -22,8 +21,8 @@
- ** ensure the GNU Lesser General Public License version 2.1 requirements
- ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- **
- -** In addition, as a special exception, Digia gives you certain additional
- -** rights. These rights are described in the Digia Qt LGPL Exception
- +** In addition, as a special exception, Nokia gives you certain additional
- +** rights. These rights are described in the Nokia Qt LGPL Exception
- ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- **
- ** GNU General Public License Usage
- @@ -34,7 +33,8 @@
- ** ensure the GNU General Public License version 3.0 requirements will be
- ** met: http://www.gnu.org/copyleft/gpl.html.
- **
- -**
- +** If you have questions regarding the use of this file, please contact
- +** Nokia at qt-info@nokia.com.
- ** $QT_END_LICENSE$
- **
- ****************************************************************************/
- @@ -252,7 +252,7 @@
- while (d->accessCount < 0 || d->waitingWriters) {
- ++d->waitingReaders;
- - bool success = d->readerWait.wait(&d->mutex, timeout < 0 ? ULONG_MAX : ulong(timeout));
- + bool success = d->readerWait.wait(&d->mutex, timeout < 0 ? ULONG_MAX : timeout);
- --d->waitingReaders;
- if (!success)
- return false;
- @@ -374,7 +374,7 @@
- while (d->accessCount != 0) {
- ++d->waitingWriters;
- - bool success = d->writerWait.wait(&d->mutex, timeout < 0 ? ULONG_MAX : ulong(timeout));
- + bool success = d->writerWait.wait(&d->mutex, timeout < 0 ? ULONG_MAX : timeout);
- --d->waitingWriters;
- if (!success)
- diff -Naurb ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qreadwritelock.h ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qreadwritelock.h
- --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qreadwritelock.h 2012-11-23 14:09:55.000000000 +0400
- +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qreadwritelock.h 2011-06-23 11:45:00.000000000 +0400
- @@ -1,18 +1,17 @@
- /****************************************************************************
- **
- -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
- -** Contact: http://www.qt-project.org/legal
- +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
- +** All rights reserved.
- +** Contact: Nokia Corporation (qt-info@nokia.com)
- **
- ** This file is part of the QtCore module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
- -** Commercial License Usage
- -** Licensees holding valid commercial Qt licenses may use this file in
- -** accordance with the commercial license agreement provided with the
- +** Commercial Usage
- +** Licensees holding valid Qt Commercial licenses may use this file in
- +** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- -** a written agreement between you and Digia. For licensing terms and
- -** conditions see http://qt.digia.com/licensing. For further information
- -** use the contact form at http://qt.digia.com/contact-us.
- +** a written agreement between you and Nokia.
- **
- ** GNU Lesser General Public License Usage
- ** Alternatively, this file may be used under the terms of the GNU Lesser
- @@ -22,8 +21,8 @@
- ** ensure the GNU Lesser General Public License version 2.1 requirements
- ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- **
- -** In addition, as a special exception, Digia gives you certain additional
- -** rights. These rights are described in the Digia Qt LGPL Exception
- +** In addition, as a special exception, Nokia gives you certain additional
- +** rights. These rights are described in the Nokia Qt LGPL Exception
- ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- **
- ** GNU General Public License Usage
- @@ -34,7 +33,8 @@
- ** ensure the GNU General Public License version 3.0 requirements will be
- ** met: http://www.gnu.org/copyleft/gpl.html.
- **
- -**
- +** If you have questions regarding the use of this file, please contact
- +** Nokia at qt-info@nokia.com.
- ** $QT_END_LICENSE$
- **
- ****************************************************************************/
- diff -Naurb ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qreadwritelock_p.h ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qreadwritelock_p.h
- --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qreadwritelock_p.h 2012-11-23 14:09:55.000000000 +0400
- +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qreadwritelock_p.h 2011-06-23 11:45:00.000000000 +0400
- @@ -1,18 +1,17 @@
- /****************************************************************************
- **
- -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
- -** Contact: http://www.qt-project.org/legal
- +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
- +** All rights reserved.
- +** Contact: Nokia Corporation (qt-info@nokia.com)
- **
- ** This file is part of the QtCore module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
- -** Commercial License Usage
- -** Licensees holding valid commercial Qt licenses may use this file in
- -** accordance with the commercial license agreement provided with the
- +** Commercial Usage
- +** Licensees holding valid Qt Commercial licenses may use this file in
- +** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- -** a written agreement between you and Digia. For licensing terms and
- -** conditions see http://qt.digia.com/licensing. For further information
- -** use the contact form at http://qt.digia.com/contact-us.
- +** a written agreement between you and Nokia.
- **
- ** GNU Lesser General Public License Usage
- ** Alternatively, this file may be used under the terms of the GNU Lesser
- @@ -22,8 +21,8 @@
- ** ensure the GNU Lesser General Public License version 2.1 requirements
- ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- **
- -** In addition, as a special exception, Digia gives you certain additional
- -** rights. These rights are described in the Digia Qt LGPL Exception
- +** In addition, as a special exception, Nokia gives you certain additional
- +** rights. These rights are described in the Nokia Qt LGPL Exception
- ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- **
- ** GNU General Public License Usage
- @@ -34,7 +33,8 @@
- ** ensure the GNU General Public License version 3.0 requirements will be
- ** met: http://www.gnu.org/copyleft/gpl.html.
- **
- -**
- +** If you have questions regarding the use of this file, please contact
- +** Nokia at qt-info@nokia.com.
- ** $QT_END_LICENSE$
- **
- ****************************************************************************/
- diff -Naurb ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qsemaphore.cpp ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qsemaphore.cpp
- --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qsemaphore.cpp 2012-11-23 14:09:55.000000000 +0400
- +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qsemaphore.cpp 2011-06-23 11:45:00.000000000 +0400
- @@ -1,18 +1,17 @@
- /****************************************************************************
- **
- -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
- -** Contact: http://www.qt-project.org/legal
- +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
- +** All rights reserved.
- +** Contact: Nokia Corporation (qt-info@nokia.com)
- **
- ** This file is part of the QtCore module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
- -** Commercial License Usage
- -** Licensees holding valid commercial Qt licenses may use this file in
- -** accordance with the commercial license agreement provided with the
- +** Commercial Usage
- +** Licensees holding valid Qt Commercial licenses may use this file in
- +** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- -** a written agreement between you and Digia. For licensing terms and
- -** conditions see http://qt.digia.com/licensing. For further information
- -** use the contact form at http://qt.digia.com/contact-us.
- +** a written agreement between you and Nokia.
- **
- ** GNU Lesser General Public License Usage
- ** Alternatively, this file may be used under the terms of the GNU Lesser
- @@ -22,8 +21,8 @@
- ** ensure the GNU Lesser General Public License version 2.1 requirements
- ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- **
- -** In addition, as a special exception, Digia gives you certain additional
- -** rights. These rights are described in the Digia Qt LGPL Exception
- +** In addition, as a special exception, Nokia gives you certain additional
- +** rights. These rights are described in the Nokia Qt LGPL Exception
- ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- **
- ** GNU General Public License Usage
- @@ -34,7 +33,8 @@
- ** ensure the GNU General Public License version 3.0 requirements will be
- ** met: http://www.gnu.org/copyleft/gpl.html.
- **
- -**
- +** If you have questions regarding the use of this file, please contact
- +** Nokia at qt-info@nokia.com.
- ** $QT_END_LICENSE$
- **
- ****************************************************************************/
- @@ -44,8 +44,6 @@
- #ifndef QT_NO_THREAD
- #include "qmutex.h"
- #include "qwaitcondition.h"
- -#include "qelapsedtimer.h"
- -#include "qdatetime.h"
- QT_BEGIN_NAMESPACE
- @@ -220,12 +218,8 @@
- while (n > d->avail)
- d->cond.wait(locker.mutex());
- } else {
- - QElapsedTimer timer;
- - timer.start();
- while (n > d->avail) {
- - const qint64 elapsed = timer.elapsed();
- - if (timeout - elapsed <= 0
- - || !d->cond.wait(locker.mutex(), timeout - elapsed))
- + if (!d->cond.wait(locker.mutex(), timeout))
- return false;
- }
- }
- diff -Naurb ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qsemaphore.h ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qsemaphore.h
- --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qsemaphore.h 2012-11-23 14:09:55.000000000 +0400
- +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qsemaphore.h 2011-06-23 11:45:00.000000000 +0400
- @@ -1,18 +1,17 @@
- /****************************************************************************
- **
- -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
- -** Contact: http://www.qt-project.org/legal
- +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
- +** All rights reserved.
- +** Contact: Nokia Corporation (qt-info@nokia.com)
- **
- ** This file is part of the QtCore module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
- -** Commercial License Usage
- -** Licensees holding valid commercial Qt licenses may use this file in
- -** accordance with the commercial license agreement provided with the
- +** Commercial Usage
- +** Licensees holding valid Qt Commercial licenses may use this file in
- +** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- -** a written agreement between you and Digia. For licensing terms and
- -** conditions see http://qt.digia.com/licensing. For further information
- -** use the contact form at http://qt.digia.com/contact-us.
- +** a written agreement between you and Nokia.
- **
- ** GNU Lesser General Public License Usage
- ** Alternatively, this file may be used under the terms of the GNU Lesser
- @@ -22,8 +21,8 @@
- ** ensure the GNU Lesser General Public License version 2.1 requirements
- ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- **
- -** In addition, as a special exception, Digia gives you certain additional
- -** rights. These rights are described in the Digia Qt LGPL Exception
- +** In addition, as a special exception, Nokia gives you certain additional
- +** rights. These rights are described in the Nokia Qt LGPL Exception
- ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- **
- ** GNU General Public License Usage
- @@ -34,7 +33,8 @@
- ** ensure the GNU General Public License version 3.0 requirements will be
- ** met: http://www.gnu.org/copyleft/gpl.html.
- **
- -**
- +** If you have questions regarding the use of this file, please contact
- +** Nokia at qt-info@nokia.com.
- ** $QT_END_LICENSE$
- **
- ****************************************************************************/
- diff -Naurb ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qthread.cpp ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qthread.cpp
- --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qthread.cpp 2012-11-23 14:09:55.000000000 +0400
- +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qthread.cpp 2013-02-14 21:08:00.000000000 +0400
- @@ -1,18 +1,17 @@
- /****************************************************************************
- **
- -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
- -** Contact: http://www.qt-project.org/legal
- +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
- +** All rights reserved.
- +** Contact: Nokia Corporation (qt-info@nokia.com)
- **
- ** This file is part of the QtCore module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
- -** Commercial License Usage
- -** Licensees holding valid commercial Qt licenses may use this file in
- -** accordance with the commercial license agreement provided with the
- +** Commercial Usage
- +** Licensees holding valid Qt Commercial licenses may use this file in
- +** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- -** a written agreement between you and Digia. For licensing terms and
- -** conditions see http://qt.digia.com/licensing. For further information
- -** use the contact form at http://qt.digia.com/contact-us.
- +** a written agreement between you and Nokia.
- **
- ** GNU Lesser General Public License Usage
- ** Alternatively, this file may be used under the terms of the GNU Lesser
- @@ -22,8 +21,8 @@
- ** ensure the GNU Lesser General Public License version 2.1 requirements
- ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- **
- -** In addition, as a special exception, Digia gives you certain additional
- -** rights. These rights are described in the Digia Qt LGPL Exception
- +** In addition, as a special exception, Nokia gives you certain additional
- +** rights. These rights are described in the Nokia Qt LGPL Exception
- ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- **
- ** GNU General Public License Usage
- @@ -34,7 +33,8 @@
- ** ensure the GNU General Public License version 3.0 requirements will be
- ** met: http://www.gnu.org/copyleft/gpl.html.
- **
- -**
- +** If you have questions regarding the use of this file, please contact
- +** Nokia at qt-info@nokia.com.
- ** $QT_END_LICENSE$
- **
- ****************************************************************************/
- @@ -78,7 +78,7 @@
- QThreadData::QThreadData(int initialRefCount)
- : _ref(initialRefCount), thread(0), threadId(0),
- - quitNow(false), loopLevel(0), eventDispatcher(0), canWait(true), isAdopted(false)
- + quitNow(false), loopLevel(0), eventDispatcher(0), canWait(true)
- {
- // fprintf(stderr, "QThreadData %p created\n", this);
- }
- @@ -149,6 +149,9 @@
- QAdoptedThread::~QAdoptedThread()
- {
- +#ifndef QT_NO_THREAD
- + QThreadPrivate::finish(this);
- +#endif
- // fprintf(stderr, "~QAdoptedThread = %p\n", this);
- }
- @@ -171,7 +174,6 @@
- QThreadPrivate::QThreadPrivate(QThreadData *d)
- : QObjectPrivate(), running(false), finished(false), terminated(false),
- - isInFinish(false), exited(false), returnCode(-1),
- stackSize(0), priority(QThread::InheritPriority), data(d)
- {
- #if defined (Q_OS_UNIX)
- @@ -197,99 +199,58 @@
- /*!
- \class QThread
- - \brief The QThread class provides a platform-independent way to
- - manage threads.
- + \brief The QThread class provides platform-independent threads.
- \ingroup thread
- - A QThread object manages one thread of control within the
- - program. To make code run in a separate thread, simply create a
- - QThread, change the thread affinity of the QObject(s) that
- - contain the code, and start() the new event loop. For example:
- + A QThread represents a separate thread of control within the
- + program; it shares data with all the other threads within the
- + process but executes independently in the way that a separate
- + program does on a multitasking operating system. Instead of
- + starting in \c main(), QThreads begin executing in run(). By
- + default, run() starts the event loop by calling exec() (see
- + below). To create your own threads, subclass QThread and
- + reimplement run(). For example:
- \snippet doc/src/snippets/code/src_corelib_thread_qthread.cpp 0
- - The code inside the Worker's slot would then execute in a
- - separate thread. In this example, the QThread triggers the
- - Worker's doWork() slot upon starting, and frees the Worker's
- - memory upon terminating. However, you are free to connect the
- - Worker's slots to any signal, from any object, in any thread. It
- - is safe to connect signals and slots across different threads,
- - thanks to a mechanism called \l{Qt::QueuedConnection}{queued
- - connections}.
- -
- - \note If you interact with an object, using any technique other
- - than queued signal/slot connections (e.g. direct function calls),
- - then the usual multithreading precautions need to be taken.
- -
- - \note It is not possible to change the thread affinity of GUI
- - objects; they must remain in the main thread.
- -
- -
- - \section1 Managing threads
- -
- - QThread will notifiy you via a signal
- + This will create a QTcpSocket in the thread and then execute the
- + thread's event loop. Use the start() method to begin execution.
- + Execution ends when you return from run(), just as an application
- + does when it leaves main(). QThread will notifiy you via a signal
- when the thread is started(), finished(), and terminated(), or
- you can use isFinished() and isRunning() to query the state of
- - the thread.
- -
- - You can stop the thread by calling exit() or quit(). In extreme
- - cases, you may want to forcibly terminate() an executing thread.
- - However, doing so is dangerous and discouraged. Please read the
- - documentation for terminate() and setTerminationEnabled() for
- - detailed information.
- -
- - From Qt 4.8 onwards, it is possible to deallocate objects that
- - live in a thread that has just ended, by connecting the
- - finished() signal to QObject::deleteLater().
- + the thread. Use wait() to block until the thread has finished
- + execution.
- - Use wait() to block the calling thread, until the other thread
- - has finished execution (or until a specified time has passed).
- + Each thread gets its own stack from the operating system. The
- + operating system also determines the default size of the stack.
- + You can use setStackSize() to set a custom stack size.
- +
- + Each QThread can have its own event loop. You can start the event
- + loop by calling exec(); you can stop it by calling exit() or
- + quit(). Having an event loop in a thread makes it possible to
- + connect signals from other threads to slots in this thread, using
- + a mechanism called \l{Qt::QueuedConnection}{queued
- + connections}. It also makes it possible to use classes that
- + require the event loop, such as QTimer and QTcpSocket, in the
- + thread. Note, however, that it is not possible to use any widget
- + classes in the thread.
- +
- + In extreme cases, you may want to forcibly terminate() an
- + executing thread. However, doing so is dangerous and discouraged.
- + Please read the documentation for terminate() and
- + setTerminationEnabled() for detailed information.
- The static functions currentThreadId() and currentThread() return
- identifiers for the currently executing thread. The former
- returns a platform specific ID for the thread; the latter returns
- a QThread pointer.
- -
- - \section1 Subclassing QThread
- -
- - Subclassing QThread is unnecessary for most purposes, since
- - QThread provides fully-functional thread management capabilities.
- - Nonetheless, QThread can be subclassed if you wish to implement
- - advanced thread management. This is done by adding new member
- - functions to the subclass, and/or by reimplementing run().
- - QThread's run() function is analogous to an application's main()
- - function -- it is executed when the thread is started, and the
- - thread will end when it returns.
- -
- - \note Prior to Qt 4.4, the only way to use QThread for parallel
- - processing was to subclass it and implement the processing code
- - inside run(). This approach is now considered \b {bad practice};
- - a QThread should only manage a thread, not process data.
- -
- - If you require event handling and signal/slot connections to
- - work in your thread, and if you reimplement run(), you must
- - explicitly call exec() at the end of your reimplementation:
- -
- - \snippet doc/src/snippets/code/src_corelib_thread_qthread.cpp 1
- -
- - QThread also provides static, platform independent sleep
- - functions: sleep(), msleep(), and usleep() allow full second,
- - millisecond, and microsecond resolution respectively.
- -
- - \note wait() and the sleep() functions should be unnecessary in
- - general, since Qt is an event-driven framework. Instead of
- - wait(), consider listening for the finished() signal. Instead of
- - the sleep() functions, consider using QTimer.
- -
- - It is important to remember that a QThread object usually lives
- - in the thread where it was created, not in the thread that it
- - manages. This oft-overlooked detail means that a QThread's slots
- - will be executed in the context of its home thread, not in the
- - context of the thread it is managing. For this reason,
- - implementing new slots in a QThread subclass is error-prone and
- - discouraged.
- + QThread also provides platform independent sleep functions in
- + varying resolutions. Use sleep() for full second resolution,
- + msleep() for millisecond resolution, and usleep() for microsecond
- + resolution.
- \sa {Thread Support in Qt}, QThreadStorage, QMutex, QSemaphore, QWaitCondition,
- {Mandelbrot Example}, {Semaphores Example}, {Wait Conditions Example}
- @@ -330,7 +291,8 @@
- /*!
- \fn void QThread::start(Priority priority)
- - Begins execution of the thread by calling run(). The
- + Begins execution of the thread by calling run(), which should be
- + reimplemented in a QThread subclass to contain your code. The
- operating system will schedule the thread according to the \a
- priority parameter. If the thread is already running, this
- function does nothing.
- @@ -393,7 +355,7 @@
- */
- /*!
- - Returns a pointer to a QThread which manages the currently
- + Returns a pointer to a QThread which represents the currently
- executing thread.
- */
- QThread *QThread::currentThread()
- @@ -404,9 +366,8 @@
- }
- /*!
- - Constructs a new QThread to manage a new thread. The \a parent
- - takes ownership of the QThread. The thread does not begin
- - executing until start() is called.
- + Constructs a new thread with the given \a parent. The thread does
- + not begin executing until start() is called.
- \sa start()
- */
- @@ -429,25 +390,20 @@
- }
- /*!
- - Destroys the QThread.
- + Destroys the thread.
- Note that deleting a QThread object will not stop the execution
- - of the thread it manages. Deleting a running QThread (i.e.
- + of the thread it represents. Deleting a running QThread (i.e.
- isFinished() returns false) will probably result in a program
- - crash. Wait for the finished() signal before deleting the
- - QThread.
- + crash. You can wait() on a thread to make sure that it has
- + finished.
- */
- QThread::~QThread()
- {
- Q_D(QThread);
- {
- QMutexLocker locker(&d->mutex);
- - if (d->isInFinish) {
- - locker.unlock();
- - wait();
- - locker.relock();
- - }
- - if (d->running && !d->finished && !d->data->isAdopted)
- + if (d->running && !d->finished)
- qWarning("QThread: Destroyed while thread is still running");
- d->data->thread = 0;
- @@ -475,12 +431,6 @@
- {
- Q_D(const QThread);
- QMutexLocker locker(&d->mutex);
- -#ifdef Q_OS_SYMBIAN
- - // app shutdown on Symbian can terminate threads and invalidate their stacks without notification,
- - // check the thread is still alive.
- - if (d->data->symbian_thread_handle.Handle() && d->data->symbian_thread_handle.ExitType() != EExitPending)
- - return false;
- -#endif
- return d->running;
- }
- @@ -532,18 +482,9 @@
- Q_D(QThread);
- QMutexLocker locker(&d->mutex);
- d->data->quitNow = false;
- - if (d->exited) {
- - d->exited = false;
- - return d->returnCode;
- - }
- - locker.unlock();
- -
- QEventLoop eventLoop;
- + locker.unlock();
- int returnCode = eventLoop.exec();
- -
- - locker.relock();
- - d->exited = false;
- - d->returnCode = -1;
- return returnCode;
- }
- @@ -561,10 +502,8 @@
- function \e does return to the caller -- it is event processing
- that stops.
- - No QEventLoops will be started anymore in this thread until
- - QThread::exec() has been called again. If the eventloop in QThread::exec()
- - is not running then the next call to QThread::exec() will also return
- - immediately.
- + This function does nothing if the thread does not have an event
- + loop.
- \sa quit() QEventLoop
- */
- @@ -572,8 +511,6 @@
- {
- Q_D(QThread);
- QMutexLocker locker(&d->mutex);
- - d->exited = true;
- - d->returnCode = returnCode;
- d->data->quitNow = true;
- for (int i = 0; i < d->data->eventLoops.size(); ++i) {
- QEventLoop *eventLoop = d->data->eventLoops.at(i);
- @@ -598,9 +535,9 @@
- newly created thread calls this function. The default
- implementation simply calls exec().
- - You can reimplement this function to facilitate advanced thread
- - management. Returning from this method will end the execution of
- - the thread.
- + You can reimplemented this function to do other useful
- + work. Returning from this method will end the execution of the
- + thread.
- \sa start() wait()
- */
- @@ -680,9 +617,7 @@
- {
- Q_D(const QThread);
- QMutexLocker locker(&d->mutex);
- -
- - // mask off the high bits that are used for flags
- - return Priority(d->priority & 0xffff);
- + return d->priority;
- }
- /*!
- @@ -696,7 +631,7 @@
- /*!
- \fn void QThread::msleep(unsigned long msecs)
- - Forces the current thread to sleep for \a msecs milliseconds.
- + Causes the current thread to sleep for \a msecs milliseconds.
- \sa sleep(), usleep()
- */
- @@ -704,7 +639,7 @@
- /*!
- \fn void QThread::usleep(unsigned long usecs)
- - Forces the current thread to sleep for \a usecs microseconds.
- + Causes the current thread to sleep for \a usecs microseconds.
- \sa sleep(), msleep()
- */
- @@ -713,17 +648,17 @@
- \fn void QThread::terminate()
- Terminates the execution of the thread. The thread may or may not
- - be terminated immediately, depending on the operating system's
- - scheduling policies. Listen for the terminated() signal, or use
- - QThread::wait() after terminate(), to be sure.
- + be terminated immediately, depending on the operating systems
- + scheduling policies. Use QThread::wait() after terminate() for
- + synchronous termination.
- When the thread is terminated, all threads waiting for the thread
- to finish will be woken up.
- \warning This function is dangerous and its use is discouraged.
- - The thread can be terminated at any point in its code path.
- + The thread can be terminate at any point in its code path.
- Threads can be terminated while modifying data. There is no
- - chance for the thread to clean up after itself, unlock any held
- + chance for the thread to cleanup after itself, unlock any held
- mutexes, etc. In short, use this function only if absolutely
- necessary.
- diff -Naurb ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qthread.h ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qthread.h
- --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qthread.h 2012-11-23 14:09:55.000000000 +0400
- +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qthread.h 2011-06-23 11:45:00.000000000 +0400
- @@ -1,18 +1,17 @@
- /****************************************************************************
- **
- -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
- -** Contact: http://www.qt-project.org/legal
- +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
- +** All rights reserved.
- +** Contact: Nokia Corporation (qt-info@nokia.com)
- **
- ** This file is part of the QtCore module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
- -** Commercial License Usage
- -** Licensees holding valid commercial Qt licenses may use this file in
- -** accordance with the commercial license agreement provided with the
- +** Commercial Usage
- +** Licensees holding valid Qt Commercial licenses may use this file in
- +** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- -** a written agreement between you and Digia. For licensing terms and
- -** conditions see http://qt.digia.com/licensing. For further information
- -** use the contact form at http://qt.digia.com/contact-us.
- +** a written agreement between you and Nokia.
- **
- ** GNU Lesser General Public License Usage
- ** Alternatively, this file may be used under the terms of the GNU Lesser
- @@ -22,8 +21,8 @@
- ** ensure the GNU Lesser General Public License version 2.1 requirements
- ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- **
- -** In addition, as a special exception, Digia gives you certain additional
- -** rights. These rights are described in the Digia Qt LGPL Exception
- +** In addition, as a special exception, Nokia gives you certain additional
- +** rights. These rights are described in the Nokia Qt LGPL Exception
- ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- **
- ** GNU General Public License Usage
- @@ -34,7 +33,8 @@
- ** ensure the GNU General Public License version 3.0 requirements will be
- ** met: http://www.gnu.org/copyleft/gpl.html.
- **
- -**
- +** If you have questions regarding the use of this file, please contact
- +** Nokia at qt-info@nokia.com.
- ** $QT_END_LICENSE$
- **
- ****************************************************************************/
- diff -Naurb ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qthread_p.h ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qthread_p.h
- --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qthread_p.h 2012-11-23 14:09:55.000000000 +0400
- +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qthread_p.h 2013-02-14 21:06:00.000000000 +0400
- @@ -1,18 +1,17 @@
- /****************************************************************************
- **
- -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
- -** Contact: http://www.qt-project.org/legal
- +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
- +** All rights reserved.
- +** Contact: Nokia Corporation (qt-info@nokia.com)
- **
- ** This file is part of the QtCore module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
- -** Commercial License Usage
- -** Licensees holding valid commercial Qt licenses may use this file in
- -** accordance with the commercial license agreement provided with the
- +** Commercial Usage
- +** Licensees holding valid Qt Commercial licenses may use this file in
- +** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- -** a written agreement between you and Digia. For licensing terms and
- -** conditions see http://qt.digia.com/licensing. For further information
- -** use the contact form at http://qt.digia.com/contact-us.
- +** a written agreement between you and Nokia.
- **
- ** GNU Lesser General Public License Usage
- ** Alternatively, this file may be used under the terms of the GNU Lesser
- @@ -22,8 +21,8 @@
- ** ensure the GNU Lesser General Public License version 2.1 requirements
- ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- **
- -** In addition, as a special exception, Digia gives you certain additional
- -** rights. These rights are described in the Digia Qt LGPL Exception
- +** In addition, as a special exception, Nokia gives you certain additional
- +** rights. These rights are described in the Nokia Qt LGPL Exception
- ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- **
- ** GNU General Public License Usage
- @@ -34,7 +33,8 @@
- ** ensure the GNU General Public License version 3.0 requirements will be
- ** met: http://www.gnu.org/copyleft/gpl.html.
- **
- -**
- +** If you have questions regarding the use of this file, please contact
- +** Nokia at qt-info@nokia.com.
- ** $QT_END_LICENSE$
- **
- ****************************************************************************/
- @@ -93,8 +93,6 @@
- return priority < pe.priority;
- }
- -// This class holds the list of posted events.
- -// The list has to be kept sorted by priority
- class QPostEventList : public QList<QPostEvent>
- {
- public:
- @@ -133,7 +131,6 @@
- };
- #ifndef QT_NO_THREAD
- -
- class QThreadPrivate : public QObjectPrivate
- {
- Q_DECLARE_PUBLIC(QThread)
- @@ -147,10 +144,6 @@
- bool running;
- bool finished;
- bool terminated;
- - bool isInFinish; //when in QThreadPrivate::finish
- -
- - bool exited;
- - int returnCode;
- uint stackSize;
- QThread::Priority priority;
- @@ -167,7 +160,6 @@
- #else
- static void finish(void *);
- #endif
- -
- #endif // Q_OS_UNIX
- #if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
- @@ -231,7 +223,8 @@
- QPostEventList postEventList;
- bool canWait;
- QVector<void *> tls;
- - bool isAdopted;
- +
- + QMutex mutex;
- # ifdef Q_OS_SYMBIAN
- RThread symbian_thread_handle;
- diff -Naurb ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qthreadstorage.cpp ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qthreadstorage.cpp
- --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qthreadstorage.cpp 2012-11-23 14:09:55.000000000 +0400
- +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qthreadstorage.cpp 2011-06-23 11:45:00.000000000 +0400
- @@ -1,18 +1,17 @@
- /****************************************************************************
- **
- -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
- -** Contact: http://www.qt-project.org/legal
- +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
- +** All rights reserved.
- +** Contact: Nokia Corporation (qt-info@nokia.com)
- **
- ** This file is part of the QtCore module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
- -** Commercial License Usage
- -** Licensees holding valid commercial Qt licenses may use this file in
- -** accordance with the commercial license agreement provided with the
- +** Commercial Usage
- +** Licensees holding valid Qt Commercial licenses may use this file in
- +** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- -** a written agreement between you and Digia. For licensing terms and
- -** conditions see http://qt.digia.com/licensing. For further information
- -** use the contact form at http://qt.digia.com/contact-us.
- +** a written agreement between you and Nokia.
- **
- ** GNU Lesser General Public License Usage
- ** Alternatively, this file may be used under the terms of the GNU Lesser
- @@ -22,8 +21,8 @@
- ** ensure the GNU Lesser General Public License version 2.1 requirements
- ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- **
- -** In addition, as a special exception, Digia gives you certain additional
- -** rights. These rights are described in the Digia Qt LGPL Exception
- +** In addition, as a special exception, Nokia gives you certain additional
- +** rights. These rights are described in the Nokia Qt LGPL Exception
- ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- **
- ** GNU General Public License Usage
- @@ -34,7 +33,8 @@
- ** ensure the GNU General Public License version 3.0 requirements will be
- ** met: http://www.gnu.org/copyleft/gpl.html.
- **
- -**
- +** If you have questions regarding the use of this file, please contact
- +** Nokia at qt-info@nokia.com.
- ** $QT_END_LICENSE$
- **
- ****************************************************************************/
- @@ -79,21 +79,6 @@
- {
- QMutexLocker locker(mutex());
- DestructorMap *destr = destructors();
- - if (!destr) {
- - /*
- - the destructors vector has already been destroyed, yet a new
- - QThreadStorage is being allocated. this can only happen during global
- - destruction, at which point we assume that there is only one thread.
- - in order to keep QThreadStorage working, we need somewhere to store
- - the data, best place we have in this situation is at the tail of the
- - current thread's tls vector. the destructor is ignored, since we have
- - no where to store it, and no way to actually call it.
- - */
- - QThreadData *data = QThreadData::current();
- - id = data->tls.count();
- - DEBUG_MSG("QThreadStorageData: Allocated id %d, destructor %p cannot be stored", id, func);
- - return;
- - }
- for (id = 0; id < destr->count(); id++) {
- if (destr->at(id) == 0)
- break;
- @@ -154,14 +139,12 @@
- data->thread);
- QMutexLocker locker(mutex());
- - DestructorMap *destr = destructors();
- - void (*destructor)(void *) = destr ? destr->value(id) : 0;
- + void (*destructor)(void *) = destructors()->value(id);
- locker.unlock();
- void *q = value;
- value = 0;
- - if (destructor)
- destructor(q);
- }
- @@ -178,12 +161,11 @@
- return; // nothing to do
- DEBUG_MSG("QThreadStorageData: Destroying storage for thread %p", QThread::currentThread());
- - while (!tls->isEmpty()) {
- - void *&value = tls->last();
- +
- + for(int i = tls->size() - 1; i >= 0; i--) {
- + void *&value = (*tls)[i];
- void *q = value;
- value = 0;
- - int i = tls->size() - 1;
- - tls->resize(i);
- if (!q) {
- // data already deleted
- @@ -201,11 +183,6 @@
- continue;
- }
- destructor(q); //crash here might mean the thread exited after qthreadstorage was destroyed
- -
- - if (tls->size() > i) {
- - //re reset the tls in case it has been recreated by its own destructor.
- - (*tls)[i] = 0;
- - }
- }
- tls->clear();
- }
- @@ -221,18 +198,19 @@
- QThreadStorage is a template class that provides per-thread data
- storage.
- + \e{Note that due to compiler limitations, QThreadStorage can only
- + store pointers.}
- +
- The setLocalData() function stores a single thread-specific value
- for the calling thread. The data can be accessed later using
- - localData().
- + localData(). QThreadStorage takes ownership of the data (which
- + must be created on the heap with \c new) and deletes it when the
- + thread exits, either normally or via termination.
- The hasLocalData() function allows the programmer to determine if
- data has previously been set using the setLocalData() function.
- This is also useful for lazy initializiation.
- - If T is a pointer type, QThreadStorage takes ownership of the data
- - (which must be created on the heap with \c new) and deletes it when
- - the thread exits, either normally or via termination.
- -
- For example, the following code uses QThreadStorage to store a
- single cache for each thread that calls the cacheObject() and
- removeFromCache() functions. The cache is automatically
- @@ -246,6 +224,9 @@
- \list
- + \o As noted above, QThreadStorage can only store pointers due to
- + compiler limitations.
- +
- \o The QThreadStorage destructor does not delete per-thread data.
- QThreadStorage only deletes per-thread data when the thread exits
- or when setLocalData() is called multiple times.
- @@ -281,11 +262,8 @@
- /*!
- \fn bool QThreadStorage::hasLocalData() const
- - If T is a pointer type, returns true if the calling thread has
- - non-zero data available.
- -
- - If T is a value type, returns whether the data has already been
- - constructed by calling setLocalData or localData.
- + Returns true if the calling thread has non-zero data available;
- + otherwise returns false.
- \sa localData()
- */
- @@ -296,8 +274,10 @@
- Returns a reference to the data that was set by the calling
- thread.
- - If no data has been set, this will create a default constructed
- - instance of type T.
- + Note: QThreadStorage can only store pointers. This function
- + returns a reference to the pointer that was set by the calling
- + thread. The value of this reference is 0 if no data was set by
- + the calling thread,
- \sa hasLocalData()
- */
- @@ -308,6 +288,10 @@
- Returns a copy of the data that was set by the calling thread.
- + Note: QThreadStorage can only store pointers. This function
- + returns a pointer to the data that was set by the calling thread.
- + If no data was set by the calling thread, this function returns 0.
- +
- \sa hasLocalData()
- */
- @@ -317,9 +301,19 @@
- Sets the local data for the calling thread to \a data. It can be
- accessed later using the localData() functions.
- - If T is a pointer type, QThreadStorage takes ownership of the data
- - and deletes it automatically either when the thread exits (either
- - normally or via termination) or when setLocalData() is called again.
- + If \a data is 0, this function deletes the previous data (if
- + any) and returns immediately.
- +
- + If \a data is non-zero, QThreadStorage takes ownership of the \a
- + data and deletes it automatically either when the thread exits
- + (either normally or via termination) or when setLocalData() is
- + called again.
- +
- + Note: QThreadStorage can only store pointers. The \a data
- + argument must be either a pointer to an object created on the heap
- + (i.e. using \c new) or 0. You should not delete \a data
- + yourself; QThreadStorage takes ownership and will delete the \a
- + data itself.
- \sa localData(), hasLocalData()
- */
- diff -Naurb ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qthreadstorage.h ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qthreadstorage.h
- --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qthreadstorage.h 2012-11-23 14:09:55.000000000 +0400
- +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qthreadstorage.h 2011-06-23 11:45:00.000000000 +0400
- @@ -1,18 +1,17 @@
- /****************************************************************************
- **
- -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
- -** Contact: http://www.qt-project.org/legal
- +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
- +** All rights reserved.
- +** Contact: Nokia Corporation (qt-info@nokia.com)
- **
- ** This file is part of the QtCore module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
- -** Commercial License Usage
- -** Licensees holding valid commercial Qt licenses may use this file in
- -** accordance with the commercial license agreement provided with the
- +** Commercial Usage
- +** Licensees holding valid Qt Commercial licenses may use this file in
- +** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- -** a written agreement between you and Digia. For licensing terms and
- -** conditions see http://qt.digia.com/licensing. For further information
- -** use the contact form at http://qt.digia.com/contact-us.
- +** a written agreement between you and Nokia.
- **
- ** GNU Lesser General Public License Usage
- ** Alternatively, this file may be used under the terms of the GNU Lesser
- @@ -22,8 +21,8 @@
- ** ensure the GNU Lesser General Public License version 2.1 requirements
- ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- **
- -** In addition, as a special exception, Digia gives you certain additional
- -** rights. These rights are described in the Digia Qt LGPL Exception
- +** In addition, as a special exception, Nokia gives you certain additional
- +** rights. These rights are described in the Nokia Qt LGPL Exception
- ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- **
- ** GNU General Public License Usage
- @@ -34,7 +33,8 @@
- ** ensure the GNU General Public License version 3.0 requirements will be
- ** met: http://www.gnu.org/copyleft/gpl.html.
- **
- -**
- +** If you have questions regarding the use of this file, please contact
- +** Nokia at qt-info@nokia.com.
- ** $QT_END_LICENSE$
- **
- ****************************************************************************/
- @@ -91,10 +91,7 @@
- void qThreadStorage_setLocalData(QThreadStorageData &d, T **t)
- { (void) d.set(*t); }
- -template <typename T>
- -inline
- -void qThreadStorage_deleteData(void *d, T **)
- -{ delete static_cast<T *>(d); }
- +#ifndef QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION
- // value-based specialization
- template <typename T>
- @@ -119,11 +116,7 @@
- void qThreadStorage_setLocalData(QThreadStorageData &d, T *t)
- { (void) d.set(new T(*t)); }
- -template <typename T>
- -inline
- -void qThreadStorage_deleteData(void *d, T *)
- -{ delete static_cast<T *>(d); }
- -
- +#endif // QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION
- // MOC_SKIP_END
- #endif
- @@ -137,7 +130,7 @@
- Q_DISABLE_COPY(QThreadStorage)
- static inline void deleteData(void *x)
- - { qThreadStorage_deleteData(x, reinterpret_cast<T*>(0)); }
- + { delete static_cast<T>(x); }
- public:
- inline QThreadStorage() : d(deleteData) { }
- diff -Naurb ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qthread_symbian.cpp ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qthread_symbian.cpp
- --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qthread_symbian.cpp 2012-11-23 14:09:55.000000000 +0400
- +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qthread_symbian.cpp 1970-01-01 03:00:00.000000000 +0300
- @@ -1,698 +0,0 @@
- -/****************************************************************************
- -**
- -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
- -** Contact: http://www.qt-project.org/legal
- -**
- -** This file is part of the QtCore module of the Qt Toolkit.
- -**
- -** $QT_BEGIN_LICENSE:LGPL$
- -** Commercial License Usage
- -** Licensees holding valid commercial Qt licenses may use this file in
- -** accordance with the commercial license agreement provided with the
- -** Software or, alternatively, in accordance with the terms contained in
- -** a written agreement between you and Digia. For licensing terms and
- -** conditions see http://qt.digia.com/licensing. For further information
- -** use the contact form at http://qt.digia.com/contact-us.
- -**
- -** GNU Lesser General Public License Usage
- -** Alternatively, this file may be used under the terms of the GNU Lesser
- -** General Public License version 2.1 as published by the Free Software
- -** Foundation and appearing in the file LICENSE.LGPL included in the
- -** packaging of this file. Please review the following information to
- -** ensure the GNU Lesser General Public License version 2.1 requirements
- -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- -**
- -** In addition, as a special exception, Digia gives you certain additional
- -** rights. These rights are described in the Digia Qt LGPL Exception
- -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- -**
- -** GNU General Public License Usage
- -** Alternatively, this file may be used under the terms of the GNU
- -** General Public License version 3.0 as published by the Free Software
- -** Foundation and appearing in the file LICENSE.GPL included in the
- -** packaging of this file. Please review the following information to
- -** ensure the GNU General Public License version 3.0 requirements will be
- -** met: http://www.gnu.org/copyleft/gpl.html.
- -**
- -**
- -** $QT_END_LICENSE$
- -**
- -****************************************************************************/
- -
- -#include "qthread.h"
- -#include "qplatformdefs.h"
- -#include <private/qcoreapplication_p.h>
- -#include <private/qeventdispatcher_symbian_p.h>
- -#include "qthreadstorage.h"
- -#include "qthread_p.h"
- -#include <private/qsystemerror_p.h>
- -#include <private/qcore_symbian_p.h>
- -
- -#include <sched.h>
- -#include <hal.h>
- -#include <hal_data.h>
- -#include <e32math.h>
- -
- -#include <QRegExp>
- -// This can be manually enabled if debugging thread problems
- -#ifdef QT_USE_RTTI_IN_THREAD_CLASSNAME
- -#include <typeinfo>
- -#endif
- -
- -// You only find these enumerations on Symbian^3 onwards, so we need to provide our own
- -// to remain compatible with older releases. They won't be called by pre-Sym^3 SDKs.
- -
- -// HALData::ENumCpus
- -#define QT_HALData_ENumCpus 119
- -
- -QT_BEGIN_NAMESPACE
- -
- -#ifndef QT_NO_THREAD
- -
- -enum { ThreadPriorityResetFlag = 0x80000000 };
- -
- -// Utility functions for getting, setting and clearing thread specific data.
- -static QThreadData *get_thread_data()
- -{
- - return reinterpret_cast<QThreadData *>(Dll::Tls());
- -}
- -
- -static void set_thread_data(QThreadData *data)
- -{
- - qt_symbian_throwIfError(Dll::SetTls(data));
- -}
- -
- -static void clear_thread_data()
- -{
- - Dll::FreeTls();
- -}
- -
- -
- -static void init_symbian_thread_handle(RThread &thread)
- -{
- - thread = RThread();
- - TThreadId threadId = thread.Id();
- - qt_symbian_throwIfError(thread.Open(threadId, EOwnerProcess));
- -}
- -
- -QThreadData *QThreadData::current()
- -{
- - QThreadData *data = get_thread_data();
- - if (!data) {
- - void *a;
- - if (QInternal::activateCallbacks(QInternal::AdoptCurrentThread, &a)) {
- - QThread *adopted = static_cast<QThread*>(a);
- - Q_ASSERT(adopted);
- - data = QThreadData::get2(adopted);
- - set_thread_data(data);
- - adopted->d_func()->running = true;
- - adopted->d_func()->finished = false;
- - static_cast<QAdoptedThread *>(adopted)->init();
- - } else {
- - data = new QThreadData;
- - QT_TRY {
- - set_thread_data(data);
- - data->thread = new QAdoptedThread(data);
- - } QT_CATCH(...) {
- - clear_thread_data();
- - data->deref();
- - data = 0;
- - QT_RETHROW;
- - }
- - data->deref();
- - }
- - data->isAdopted = true;
- - data->threadId = QThread::currentThreadId();
- - if (!QCoreApplicationPrivate::theMainThread)
- - QCoreApplicationPrivate::theMainThread = data->thread;
- - }
- - return data;
- -}
- -
- -
- -class QCAdoptedThreadMonitor : public CActive
- -{
- -public:
- - QCAdoptedThreadMonitor(QThread *thread)
- - : CActive(EPriorityStandard), data(QThreadData::get2(thread))
- - {
- - CActiveScheduler::Add(this);
- - data->symbian_thread_handle.Logon(iStatus);
- - SetActive();
- - }
- - ~QCAdoptedThreadMonitor()
- - {
- - Cancel();
- - }
- - void DoCancel()
- - {
- - data->symbian_thread_handle.LogonCancel(iStatus);
- - }
- - void RunL();
- -private:
- - QThreadData* data;
- -};
- -
- -class QCAddAdoptedThread : public CActive
- -{
- -public:
- - QCAddAdoptedThread()
- - : CActive(EPriorityStandard)
- - {
- - CActiveScheduler::Add(this);
- - }
- - void ConstructL()
- - {
- - User::LeaveIfError(monitorThread.Open(RThread().Id()));
- - start();
- - }
- - ~QCAddAdoptedThread()
- - {
- - Cancel();
- - monitorThread.Close();
- - }
- - void DoCancel()
- - {
- - User::RequestComplete(stat, KErrCancel);
- - }
- - void start()
- - {
- - iStatus = KRequestPending;
- - SetActive();
- - stat = &iStatus;
- - }
- - void RunL()
- - {
- - if (iStatus.Int() != KErrNone)
- - return;
- -
- - QMutexLocker adoptedThreadMonitorMutexlock(&adoptedThreadMonitorMutex);
- - for (int i=threadsToAdd.size()-1; i>=0; i--) {
- - // Create an active object to monitor the thread
- - new (ELeave) QCAdoptedThreadMonitor(threadsToAdd[i]);
- - count++;
- - threadsToAdd.pop_back();
- - }
- - start();
- - }
- - static void add(QThread *thread)
- - {
- - QMutexLocker adoptedThreadMonitorMutexlock(&adoptedThreadMonitorMutex);
- - if (!adoptedThreadAdder) {
- - RThread monitorThread;
- - qt_symbian_throwIfError(monitorThread.Create(KNullDesC(), &monitorThreadFunc, 1024, &User::Allocator(), 0));
- - TRequestStatus started;
- - monitorThread.Rendezvous(started);
- - monitorThread.Resume();
- - User::WaitForRequest(started);
- - monitorThread.Close();
- - }
- - if (RThread().Id() == adoptedThreadAdder->monitorThread.Id())
- - return;
- - adoptedThreadAdder->threadsToAdd.push_back(thread);
- - if (adoptedThreadAdder->stat) {
- - adoptedThreadAdder->monitorThread.RequestComplete(adoptedThreadAdder->stat, KErrNone);
- - }
- - }
- - static void monitorThreadFuncL()
- - {
- - CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
- - CleanupStack::PushL(scheduler);
- - CActiveScheduler::Install(scheduler);
- -
- - adoptedThreadAdder = new(ELeave) QCAddAdoptedThread();
- - CleanupStack::PushL(adoptedThreadAdder);
- - adoptedThreadAdder->ConstructL();
- - QCAddAdoptedThread *adder = adoptedThreadAdder;
- -
- - RThread::Rendezvous(KErrNone);
- - CActiveScheduler::Start();
- -
- - CleanupStack::PopAndDestroy(adder);
- - CleanupStack::PopAndDestroy(scheduler);
- - }
- - static int monitorThreadFunc(void *)
- - {
- - _LIT(KMonitorThreadName, "adoptedMonitorThread");
- - RThread::RenameMe(KMonitorThreadName());
- - CTrapCleanup* cleanup = CTrapCleanup::New();
- - TRAPD(ret, monitorThreadFuncL());
- - delete cleanup;
- - return ret;
- - }
- - static void threadDied()
- - {
- - QMutexLocker adoptedThreadMonitorMutexlock(&adoptedThreadMonitorMutex);
- - if (adoptedThreadAdder) {
- - adoptedThreadAdder->count--;
- - if (adoptedThreadAdder->count <= 0 && adoptedThreadAdder->threadsToAdd.size() == 0) {
- - CActiveScheduler::Stop();
- - adoptedThreadAdder = 0;
- - }
- - }
- - }
- -
- -private:
- - QVector<QThread*> threadsToAdd;
- - RThread monitorThread;
- - static QMutex adoptedThreadMonitorMutex;
- - static QCAddAdoptedThread *adoptedThreadAdder;
- - int count;
- - TRequestStatus *stat;
- -};
- -
- -QMutex QCAddAdoptedThread::adoptedThreadMonitorMutex;
- -QCAddAdoptedThread* QCAddAdoptedThread::adoptedThreadAdder = 0;
- -
- -static void finishAdoptedThread(QThreadData* data, bool closeNativeHandle)
- -{
- - if (data->isAdopted) {
- - QThread *thread = data->thread;
- - Q_ASSERT(thread);
- - QThreadPrivate *thread_p = static_cast<QThreadPrivate *>(QObjectPrivate::get(thread));
- - if (!thread_p->finished)
- - thread_p->finish(thread, true, closeNativeHandle);
- - else if (closeNativeHandle && data->symbian_thread_handle.Handle())
- - data->symbian_thread_handle.Close();
- - }
- -}
- -
- -void QCAdoptedThreadMonitor::RunL()
- -{
- - // clean up the thread, or close the handle if that's all that's left
- - finishAdoptedThread(data, true);
- - data->deref();
- - QCAddAdoptedThread::threadDied();
- - delete this;
- -}
- -
- -static pthread_once_t current_thread_data_once = PTHREAD_ONCE_INIT;
- -static pthread_key_t current_thread_data_key;
- -
- -static void pthread_in_thread_cleanup(void *p)
- -{
- - QThreadData *data = static_cast<QThreadData *>(p);
- - // clean up the thread, but leave the handle for adoptedThreadMonitor
- - finishAdoptedThread(data, false);
- -}
- -
- -static void create_current_thread_data_key()
- -{
- - pthread_key_create(¤t_thread_data_key, pthread_in_thread_cleanup);
- -}
- -
- -static void destroy_current_thread_data_key()
- -{
- - pthread_once(¤t_thread_data_once, create_current_thread_data_key);
- - pthread_key_delete(current_thread_data_key);
- -}
- -Q_DESTRUCTOR_FUNCTION(destroy_current_thread_data_key)
- -
- -void QAdoptedThread::init()
- -{
- - Q_D(QThread);
- - d->thread_id = RThread().Id(); // type operator to TUint
- - init_symbian_thread_handle(d->data->symbian_thread_handle);
- - QCAddAdoptedThread::add(this);
- - pthread_once(¤t_thread_data_once, create_current_thread_data_key);
- - pthread_setspecific(current_thread_data_key, get_thread_data());
- -}
- -
- -/*
- - QThreadPrivate
- -*/
- -
- -#if defined(Q_C_CALLBACKS)
- -extern "C" {
- -#endif
- -
- -typedef void*(*QtThreadCallback)(void*);
- -
- -#if defined(Q_C_CALLBACKS)
- -}
- -#endif
- -
- -#endif // QT_NO_THREAD
- -
- -void QThreadPrivate::createEventDispatcher(QThreadData *data)
- -{
- - data->eventDispatcher = new QEventDispatcherSymbian;
- - data->eventDispatcher->startingUp();
- -}
- -
- -#ifndef QT_NO_THREAD
- -
- -void *QThreadPrivate::start(void *arg)
- -{
- - QThread *thr = reinterpret_cast<QThread *>(arg);
- - QThreadData *data = QThreadData::get2(thr);
- -
- - // do we need to reset the thread priority?
- - if (int(thr->d_func()->priority) & ThreadPriorityResetFlag) {
- - thr->setPriority(QThread::Priority(thr->d_func()->priority & ~ThreadPriorityResetFlag));
- - }
- -
- - // 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);
- -
- - data->threadId = QThread::currentThreadId();
- - set_thread_data(data);
- -
- - CTrapCleanup *cleanup = CTrapCleanup::New();
- - q_check_ptr(cleanup);
- -
- - {
- - QMutexLocker locker(&thr->d_func()->mutex);
- - data->quitNow = thr->d_func()->exited;
- - }
- -
- - // ### TODO: allow the user to create a custom event dispatcher
- - createEventDispatcher(data);
- -
- - TRAPD(err, {
- - try {
- - emit thr->started();
- - thr->run();
- - } catch (const std::exception& ex) {
- - qWarning("QThreadPrivate::start: Thread exited on exception %s", ex.what());
- - User::Leave(KErrGeneral); // leave to force cleanup stack cleanup
- - }
- - });
- - if (err)
- - qWarning("QThreadPrivate::start: Thread exited on leave %d", err);
- -
- - // finish emits signals which should be wrapped in a trap for Symbian code, but otherwise ignore leaves and exceptions.
- - TRAP(err, {
- - try {
- - QThreadPrivate::finish(arg);
- - } catch (const std::exception& ex) {
- - User::Leave(KErrGeneral); // leave to force cleanup stack cleanup
- - }
- - });
- -
- - delete cleanup;
- -
- - return 0;
- -}
- -
- -void QThreadPrivate::finish(void *arg, bool lockAnyway, bool closeNativeHandle)
- -{
- - QThread *thr = reinterpret_cast<QThread *>(arg);
- - QThreadPrivate *d = thr->d_func();
- -
- - QMutexLocker locker(lockAnyway ? &d->mutex : 0);
- -
- - d->isInFinish = true;
- - d->priority = QThread::InheritPriority;
- - bool terminated = d->terminated;
- - void *data = &d->data->tls;
- - locker.unlock();
- - if (terminated)
- - emit thr->terminated();
- - emit thr->finished();
- - QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- - QThreadStorageData::finish((void **)data);
- - locker.relock();
- - d->terminated = false;
- -
- - QAbstractEventDispatcher *eventDispatcher = d->data->eventDispatcher;
- - if (eventDispatcher) {
- - d->data->eventDispatcher = 0;
- - locker.unlock();
- - eventDispatcher->closingDown();
- - delete eventDispatcher;
- - locker.relock();
- - }
- -
- - d->thread_id = 0;
- - if (closeNativeHandle)
- - d->data->symbian_thread_handle.Close();
- - d->running = false;
- - d->finished = true;
- -
- - d->isInFinish = false;
- - d->thread_done.wakeAll();
- -}
- -
- -
- -
- -
- -/**************************************************************************
- - ** QThread
- - *************************************************************************/
- -
- -Qt::HANDLE QThread::currentThreadId()
- -{
- - return (Qt::HANDLE) (TUint) RThread().Id();
- -}
- -
- -int QThread::idealThreadCount()
- -{
- - int cores = 1;
- -
- - if (QSysInfo::symbianVersion() >= QSysInfo::SV_SF_3) {
- - TInt inumcpus;
- - TInt err;
- - err = HAL::Get((HALData::TAttribute)QT_HALData_ENumCpus, inumcpus);
- - if (err == KErrNone) {
- - cores = qMax(inumcpus, 1);
- - }
- - }
- -
- - return cores;
- -}
- -
- -void QThread::yieldCurrentThread()
- -{
- - sched_yield();
- -}
- -
- -/* \internal
- - helper function to do thread sleeps
- -*/
- -static void thread_sleep(unsigned long remaining, unsigned long scale)
- -{
- - // maximum Symbian wait is 2^31 microseconds
- - unsigned long maxWait = KMaxTInt / scale;
- - do {
- - unsigned long waitTime = qMin(maxWait, remaining);
- - remaining -= waitTime;
- - User::AfterHighRes(waitTime * scale);
- - } while (remaining);
- -}
- -
- -void QThread::sleep(unsigned long secs)
- -{
- - thread_sleep(secs, 1000000ul);
- -}
- -
- -void QThread::msleep(unsigned long msecs)
- -{
- - thread_sleep(msecs, 1000ul);
- -}
- -
- -void QThread::usleep(unsigned long usecs)
- -{
- - thread_sleep(usecs, 1ul);
- -}
- -
- -TThreadPriority calculateSymbianPriority(QThread::Priority priority)
- - {
- - // Both Qt & Symbian use limited enums; this matches the mapping previously done through conversion to Posix granularity
- - TThreadPriority symPriority;
- - switch (priority)
- - {
- - case QThread::IdlePriority:
- - symPriority = EPriorityMuchLess;
- - break;
- - case QThread::LowestPriority:
- - case QThread::LowPriority:
- - symPriority = EPriorityLess;
- - break;
- - case QThread::NormalPriority:
- - symPriority = EPriorityNormal;
- - break;
- - case QThread::HighPriority:
- - symPriority = EPriorityMore;
- - break;
- - case QThread::HighestPriority:
- - case QThread::TimeCriticalPriority:
- - symPriority = EPriorityMuchMore;
- - break;
- - case QThread::InheritPriority:
- - default:
- - symPriority = RThread().Priority();
- - break;
- - }
- - return symPriority;
- - }
- -
- -void QThread::start(Priority priority)
- -{
- - Q_D(QThread);
- - QMutexLocker locker(&d->mutex);
- -
- - if (d->isInFinish)
- - d->thread_done.wait(locker.mutex());
- -
- - if (d->running)
- - return;
- -
- - d->running = true;
- - d->finished = false;
- - d->terminated = false;
- - d->returnCode = 0;
- - d->exited = false;
- -
- - d->priority = priority;
- -
- - if (d->stackSize == 0)
- - // The default stack size on Symbian is very small, making even basic
- - // operations like file I/O fail, so we increase it by default.
- - d->stackSize = 0x14000; // Maximum stack size on Symbian.
- -
- - int code = KErrAlreadyExists;
- - QString className(QLatin1String(metaObject()->className()));
- -#ifdef QT_USE_RTTI_IN_THREAD_CLASSNAME
- - // use RTTI, if enabled, to get a more accurate className. This must be manually enabled.
- - const char* rttiName = typeid(*this).name();
- - if (rttiName)
- - className = QLatin1String(rttiName);
- -#endif
- - QString threadNameBase = QString(QLatin1String("%1_%2_v=0x%3_")).arg(objectName()).arg(className).arg(*(uint*)this,8,16,QLatin1Char('0'));
- - // Thread name can contain only characters allowed by User::ValidateName() otherwise RThread::Create fails.
- - // Not allowed characters are:
- - // - any character outside range 0x20 - 0x7e
- - // - or asterisk, question mark or colon
- - const QRegExp notAllowedChars(QLatin1String("[^\\x20-\\x7e]|\\*|\\?|\\:"));
- - threadNameBase.replace(notAllowedChars, QLatin1String("_"));
- -
- - TPtrC threadNameBasePtr(qt_QString2TPtrC(threadNameBase));
- - // max thread name length is KMaxKernelName
- - TBuf<KMaxKernelName> name;
- - threadNameBasePtr.Set(threadNameBasePtr.Left(qMin(threadNameBasePtr.Length(), name.MaxLength() - 8)));
- - const int MaxRetries = 10;
- - for (int i=0; i<MaxRetries && code == KErrAlreadyExists; i++) {
- - // generate a thread name with a random component to avoid and resolve name collisions
- - // a named thread can be opened from another process
- - name.Zero();
- - name.Append(threadNameBasePtr);
- - name.AppendNumFixedWidth(Math::Random(), EHex, 8);
- - code = d->data->symbian_thread_handle.Create(name, (TThreadFunction) QThreadPrivate::start, d->stackSize, NULL, this);
- - }
- - if (code == KErrNone) {
- - d->thread_id = d->data->symbian_thread_handle.Id();
- - TThreadPriority symPriority = calculateSymbianPriority(priority);
- - d->data->symbian_thread_handle.SetPriority(symPriority);
- - d->data->symbian_thread_handle.Resume();
- - } else {
- - qWarning("QThread::start: Thread creation error: %s", qPrintable(QSystemError(code, QSystemError::NativeError).toString()));
- -
- - d->running = false;
- - d->finished = false;
- - d->thread_id = 0;
- - d->data->symbian_thread_handle.Close();
- - }
- -}
- -
- -void QThread::terminate()
- -{
- - Q_D(QThread);
- - QMutexLocker locker(&d->mutex);
- -
- - if (!d->thread_id)
- - return;
- -
- - if (!d->running)
- - return;
- - if (!d->terminationEnabled) {
- - d->terminatePending = true;
- - return;
- - }
- -
- - d->terminated = true;
- - // "false, false" meaning:
- - // 1. lockAnyway = false. Don't lock the mutex because it's already locked
- - // (see above).
- - // 2. closeNativeSymbianHandle = false. We don't want to close the thread handle,
- - // because we need it here to terminate the thread.
- - QThreadPrivate::finish(this, false, false);
- - d->data->symbian_thread_handle.Terminate(KErrNone);
- - d->data->symbian_thread_handle.Close();
- -}
- -
- -bool QThread::wait(unsigned long time)
- -{
- - Q_D(QThread);
- - QMutexLocker locker(&d->mutex);
- -
- - if (d->thread_id == (TUint) RThread().Id()) {
- - qWarning("QThread::wait: Thread tried to wait on itself");
- - return false;
- - }
- -
- - if (d->finished || !d->running)
- - return true;
- -
- - while (d->running) {
- - // Check if thread still exists. Needed because kernel will kill it without notification
- - // before global statics are deleted at application exit.
- - if (d->data->symbian_thread_handle.Handle()
- - && d->data->symbian_thread_handle.ExitType() != EExitPending) {
- - // Cannot call finish here as wait is typically called from another thread.
- - // It won't be necessary anyway, as we should never get here under normal operations;
- - // all QThreads are EProcessCritical and therefore cannot normally exit
- - // undetected (i.e. panic) as long as all thread control is via QThread.
- - return true;
- - }
- - if (!d->thread_done.wait(locker.mutex(), time))
- - return false;
- - }
- - return true;
- -}
- -
- -void QThread::setTerminationEnabled(bool enabled)
- -{
- - QThread *thr = currentThread();
- - Q_ASSERT_X(thr != 0, "QThread::setTerminationEnabled()",
- - "Current thread was not started with QThread.");
- - QThreadPrivate *d = thr->d_func();
- - QMutexLocker locker(&d->mutex);
- - d->terminationEnabled = enabled;
- - if (enabled && d->terminatePending) {
- - d->terminated = true;
- - // "false" meaning:
- - // - lockAnyway = false. Don't lock the mutex because it's already locked
- - // (see above).
- - QThreadPrivate::finish(thr, false);
- - locker.unlock(); // don't leave the mutex locked!
- - User::Exit(0); // may be some other cleanup required? what if AS or cleanup stack?
- - }
- -}
- -
- -void QThread::setPriority(Priority priority)
- -{
- - Q_D(QThread);
- - QMutexLocker locker(&d->mutex);
- - if (!d->running) {
- - qWarning("QThread::setPriority: Cannot set priority, thread is not running");
- - return;
- - }
- -
- - d->priority = priority;
- -
- - // copied from start() with a few modifications:
- - TThreadPriority symPriority = calculateSymbianPriority(priority);
- - d->data->symbian_thread_handle.SetPriority(symPriority);
- -}
- -
- -#endif // QT_NO_THREAD
- -
- -QT_END_NAMESPACE
- -
- diff -Naurb ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qthread_unix.cpp ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qthread_unix.cpp
- --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qthread_unix.cpp 2012-11-23 14:09:55.000000000 +0400
- +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qthread_unix.cpp 2013-02-14 21:08:00.000000000 +0400
- @@ -1,18 +1,17 @@
- /****************************************************************************
- **
- -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
- -** Contact: http://www.qt-project.org/legal
- +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
- +** All rights reserved.
- +** Contact: Nokia Corporation (qt-info@nokia.com)
- **
- ** This file is part of the QtCore module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
- -** Commercial License Usage
- -** Licensees holding valid commercial Qt licenses may use this file in
- -** accordance with the commercial license agreement provided with the
- +** Commercial Usage
- +** Licensees holding valid Qt Commercial licenses may use this file in
- +** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- -** a written agreement between you and Digia. For licensing terms and
- -** conditions see http://qt.digia.com/licensing. For further information
- -** use the contact form at http://qt.digia.com/contact-us.
- +** a written agreement between you and Nokia.
- **
- ** GNU Lesser General Public License Usage
- ** Alternatively, this file may be used under the terms of the GNU Lesser
- @@ -22,8 +21,8 @@
- ** ensure the GNU Lesser General Public License version 2.1 requirements
- ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- **
- -** In addition, as a special exception, Digia gives you certain additional
- -** rights. These rights are described in the Digia Qt LGPL Exception
- +** In addition, as a special exception, Nokia gives you certain additional
- +** rights. These rights are described in the Nokia Qt LGPL Exception
- ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- **
- ** GNU General Public License Usage
- @@ -34,7 +33,8 @@
- ** ensure the GNU General Public License version 3.0 requirements will be
- ** met: http://www.gnu.org/copyleft/gpl.html.
- **
- -**
- +** If you have questions regarding the use of this file, please contact
- +** Nokia at qt-info@nokia.com.
- ** $QT_END_LICENSE$
- **
- ****************************************************************************/
- @@ -44,14 +44,14 @@
- #include "qplatformdefs.h"
- #include <private/qcoreapplication_p.h>
- +#if !defined(QT_NO_GLIB)
- +# include "../kernel/qeventdispatcher_glib_p.h"
- +#endif
- -#if defined(Q_OS_BLACKBERRY)
- -# include <private/qeventdispatcher_blackberry_p.h>
- +#ifdef Q_OS_SYMBIAN
- +#include <private/qeventdispatcher_symbian_p.h>
- #else
- -# if !defined(QT_NO_GLIB)
- -# include "../kernel/qeventdispatcher_glib_p.h"
- -# endif
- -# include <private/qeventdispatcher_unix_p.h>
- +#include <private/qeventdispatcher_unix_p.h>
- #endif
- #include "qthreadstorage.h"
- @@ -83,9 +83,7 @@
- # define old_qDebug qDebug
- # undef qDebug
- # endif
- -#if !defined(Q_OS_IOS)
- # include <CoreServices/CoreServices.h>
- -#endif // !defined(Q_OS_IOS)
- # ifdef old_qDebug
- # undef qDebug
- @@ -94,37 +92,10 @@
- # endif
- #endif
- -#if defined(Q_OS_LINUX) && !defined(QT_LINUXBASE)
- -#include <sys/prctl.h>
- -#endif
- -
- -#if defined(Q_OS_LINUX) && !defined(SCHED_IDLE)
- -// from linux/sched.h
- -# define SCHED_IDLE 5
- -#endif
- -
- -#if defined(Q_OS_DARWIN) || !defined(Q_OS_OPENBSD) && defined(_POSIX_THREAD_PRIORITY_SCHEDULING) && (_POSIX_THREAD_PRIORITY_SCHEDULING-0 >= 0)
- -#define QT_HAS_THREAD_PRIORITY_SCHEDULING
- -#endif
- -
- -
- QT_BEGIN_NAMESPACE
- #ifndef QT_NO_THREAD
- -enum { ThreadPriorityResetFlag = 0x80000000 };
- -
- -#if defined(Q_OS_LINUX) && defined(__GLIBC__) && (defined(Q_CC_GNU) || defined(Q_CC_INTEL))
- -#define HAVE_TLS
- -#endif
- -#if defined(Q_CC_XLC) || defined (Q_CC_SUN)
- -#define HAVE_TLS
- -#endif
- -
- -#ifdef HAVE_TLS
- -static __thread QThreadData *currentThreadData = 0;
- -#endif
- -
- static pthread_once_t current_thread_data_once = PTHREAD_ONCE_INIT;
- static pthread_key_t current_thread_data_key;
- @@ -141,16 +112,7 @@
- // this destructor function, so we need to set it back to the
- // right value...
- pthread_setspecific(current_thread_data_key, p);
- - QThreadData *data = static_cast<QThreadData *>(p);
- - if (data->isAdopted) {
- - QThread *thread = data->thread;
- - Q_ASSERT(thread);
- - QThreadPrivate *thread_p = static_cast<QThreadPrivate *>(QObjectPrivate::get(thread));
- - Q_ASSERT(!thread_p->finished);
- - thread_p->finish(thread);
- - }
- - data->deref();
- -
- + reinterpret_cast<QThreadData *>(p)->deref();
- // ... but we must reset it to zero before returning so we aren't
- // called again (POSIX allows implementations to call destructor
- // functions repeatedly until all values are zero)
- @@ -167,69 +129,34 @@
- pthread_key_create(¤t_thread_data_key, destroy_current_thread_data);
- }
- -static void destroy_current_thread_data_key()
- -{
- - pthread_once(¤t_thread_data_once, create_current_thread_data_key);
- - pthread_key_delete(current_thread_data_key);
- -}
- -Q_DESTRUCTOR_FUNCTION(destroy_current_thread_data_key)
- -
- -
- -// Utility functions for getting, setting and clearing thread specific data.
- -static QThreadData *get_thread_data()
- -{
- -#ifdef HAVE_TLS
- - return currentThreadData;
- -#else
- - pthread_once(¤t_thread_data_once, create_current_thread_data_key);
- - return reinterpret_cast<QThreadData *>(pthread_getspecific(current_thread_data_key));
- -#endif
- -}
- -
- -static void set_thread_data(QThreadData *data)
- +QThreadData *QThreadData::current()
- {
- -#ifdef HAVE_TLS
- - currentThreadData = data;
- -#endif
- pthread_once(¤t_thread_data_once, create_current_thread_data_key);
- - pthread_setspecific(current_thread_data_key, data);
- -}
- -
- -static void clear_thread_data()
- -{
- -#ifdef HAVE_TLS
- - currentThreadData = 0;
- -#endif
- - pthread_setspecific(current_thread_data_key, 0);
- -}
- -QThreadData *QThreadData::current()
- -{
- - QThreadData *data = get_thread_data();
- + QThreadData *data = reinterpret_cast<QThreadData *>(pthread_getspecific(current_thread_data_key));
- if (!data) {
- void *a;
- if (QInternal::activateCallbacks(QInternal::AdoptCurrentThread, &a)) {
- QThread *adopted = static_cast<QThread*>(a);
- Q_ASSERT(adopted);
- data = QThreadData::get2(adopted);
- - set_thread_data(data);
- + pthread_setspecific(current_thread_data_key, data);
- adopted->d_func()->running = true;
- adopted->d_func()->finished = false;
- static_cast<QAdoptedThread *>(adopted)->init();
- } else {
- data = new QThreadData;
- + pthread_setspecific(current_thread_data_key, data);
- QT_TRY {
- - set_thread_data(data);
- data->thread = new QAdoptedThread(data);
- } QT_CATCH(...) {
- - clear_thread_data();
- + pthread_setspecific(current_thread_data_key, 0);
- data->deref();
- data = 0;
- QT_RETHROW;
- }
- data->deref();
- }
- - data->isAdopted = true;
- data->threadId = (Qt::HANDLE)pthread_self();
- if (!QCoreApplicationPrivate::theMainThread)
- QCoreApplicationPrivate::theMainThread = data->thread;
- @@ -242,6 +169,11 @@
- {
- Q_D(QThread);
- d->thread_id = pthread_self();
- +#ifdef Q_OS_SYMBIAN
- + d->data->symbian_thread_handle = RThread();
- + TThreadId threadId = d->data->symbian_thread_handle.Id();
- + d->data->symbian_thread_handle.Open(threadId);
- +#endif
- }
- /*
- @@ -262,9 +194,6 @@
- void QThreadPrivate::createEventDispatcher(QThreadData *data)
- {
- -#if defined(Q_OS_BLACKBERRY)
- - data->eventDispatcher = new QEventDispatcherBlackberry;
- -#else
- #if !defined(QT_NO_GLIB)
- if (qgetenv("QT_NO_GLIB").isEmpty()
- && qgetenv("QT_NO_THREADED_GLIB").isEmpty()
- @@ -272,111 +201,104 @@
- data->eventDispatcher = new QEventDispatcherGlib;
- else
- #endif
- +#ifdef Q_OS_SYMBIAN
- + data->eventDispatcher = new QEventDispatcherSymbian;
- +#else
- data->eventDispatcher = new QEventDispatcherUNIX;
- #endif
- -
- data->eventDispatcher->startingUp();
- }
- #ifndef QT_NO_THREAD
- -#if (defined(Q_OS_LINUX) || (defined(Q_OS_MAC) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6) || defined(Q_OS_QNX))
- -static void setCurrentThreadName(pthread_t threadId, const char *name)
- -{
- -# if defined(Q_OS_LINUX) && !defined(QT_LINUXBASE)
- - Q_UNUSED(threadId);
- - prctl(PR_SET_NAME, (unsigned long)name, 0, 0, 0);
- -# elif (defined(Q_OS_MAC) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6)
- - Q_UNUSED(threadId);
- - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_6)
- - pthread_setname_np(name);
- -# elif defined(Q_OS_QNX)
- - pthread_setname_np(threadId, name);
- -# endif
- -}
- -#endif
- -
- void *QThreadPrivate::start(void *arg)
- {
- + // Symbian Open C supports neither thread cancellation nor cleanup_push.
- +#ifndef Q_OS_SYMBIAN
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
- pthread_cleanup_push(QThreadPrivate::finish, arg);
- +#endif
- QThread *thr = reinterpret_cast<QThread *>(arg);
- QThreadData *data = QThreadData::get2(thr);
- + data->threadId = (Qt::HANDLE)pthread_self();
- - // do we need to reset the thread priority?
- - if (int(thr->d_func()->priority) & ThreadPriorityResetFlag) {
- - thr->setPriority(QThread::Priority(thr->d_func()->priority & ~ThreadPriorityResetFlag));
- - }
- +#ifdef Q_OS_SYMBIAN
- + // Because Symbian Open C does not provide a way to convert between
- + // RThread and pthread_t, we must delay initialization of the RThread
- + // handle when creating a thread, until we are running in the new thread.
- + // Here, we pick up the current thread and assign that to the handle.
- + data->symbian_thread_handle = RThread();
- + TThreadId threadId = data->symbian_thread_handle.Id();
- + data->symbian_thread_handle.Open(threadId);
- +#endif
- - data->threadId = (Qt::HANDLE)pthread_self();
- - set_thread_data(data);
- + pthread_once(¤t_thread_data_once, create_current_thread_data_key);
- + pthread_setspecific(current_thread_data_key, data);
- data->ref();
- - {
- - QMutexLocker locker(&thr->d_func()->mutex);
- - data->quitNow = thr->d_func()->exited;
- - }
- + data->quitNow = false;
- // ### TODO: allow the user to create a custom event dispatcher
- createEventDispatcher(data);
- -#if (defined(Q_OS_LINUX) || (defined(Q_OS_MAC) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6) || defined(Q_OS_QNX))
- - // sets the name of the current thread.
- - QString objectName = thr->objectName();
- -
- - if (Q_LIKELY(objectName.isEmpty()))
- - setCurrentThreadName(thr->d_func()->thread_id, thr->metaObject()->className());
- - else
- - setCurrentThreadName(thr->d_func()->thread_id, objectName.toLocal8Bit());
- -
- -#endif
- -
- emit thr->started();
- +#ifndef Q_OS_SYMBIAN
- pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
- pthread_testcancel();
- +#endif
- thr->run();
- +#ifdef Q_OS_SYMBIAN
- + QThreadPrivate::finish(arg);
- +#else
- pthread_cleanup_pop(1);
- +#endif
- return 0;
- }
- +#ifdef Q_OS_SYMBIAN
- +void QThreadPrivate::finish(void *arg, bool lockAnyway, bool closeNativeHandle)
- +#else
- void QThreadPrivate::finish(void *arg)
- +#endif
- {
- QThread *thr = reinterpret_cast<QThread *>(arg);
- QThreadPrivate *d = thr->d_func();
- +#ifdef Q_OS_SYMBIAN
- + if (lockAnyway)
- +#endif
- + d->mutex.lock();
- - QMutexLocker locker(&d->mutex);
- -
- - d->isInFinish = true;
- d->priority = QThread::InheritPriority;
- - bool terminated = d->terminated;
- - void *data = &d->data->tls;
- - locker.unlock();
- - if (terminated)
- + d->running = false;
- + d->finished = true;
- + if (d->terminated)
- emit thr->terminated();
- - emit thr->finished();
- - QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- - QThreadStorageData::finish((void **)data);
- - locker.relock();
- d->terminated = false;
- + emit thr->finished();
- + if (d->data->eventDispatcher) {
- + d->data->eventDispatcher->closingDown();
- QAbstractEventDispatcher *eventDispatcher = d->data->eventDispatcher;
- - if (eventDispatcher) {
- d->data->eventDispatcher = 0;
- - locker.unlock();
- - eventDispatcher->closingDown();
- delete eventDispatcher;
- - locker.relock();
- }
- - d->thread_id = 0;
- - d->running = false;
- - d->finished = true;
- + void *data = &d->data->tls;
- + QThreadStorageData::finish((void **)data);
- - d->isInFinish = false;
- + d->thread_id = 0;
- +#ifdef Q_OS_SYMBIAN
- + if (closeNativeHandle)
- + d->data->symbian_thread_handle.Close();
- +#endif
- d->thread_done.wakeAll();
- +#ifdef Q_OS_SYMBIAN
- + if (lockAnyway)
- +#endif
- + d->mutex.unlock();
- }
- @@ -401,7 +323,7 @@
- {
- int cores = -1;
- -#if defined(Q_OS_MAC) && !defined(Q_WS_QPA)
- +#if defined(Q_OS_MAC)
- // Mac OS X
- cores = MPProcessorsScheduled();
- #elif defined(Q_OS_HPUX)
- @@ -429,6 +351,9 @@
- #elif defined(Q_OS_INTEGRITY)
- // as of aug 2008 Integrity only supports one single core CPU
- cores = 1;
- +#elif defined(Q_OS_SYMBIAN)
- + // ### TODO - Get the number of cores from HAL? when multicore architectures (SMP) are supported
- + cores = 1;
- #elif defined(Q_OS_VXWORKS)
- // VxWorks
- # if defined(QT_VXWORKS_HAS_CPUSET)
- @@ -513,60 +438,16 @@
- thread_sleep(&ti);
- }
- -#ifdef QT_HAS_THREAD_PRIORITY_SCHEDULING
- -// Does some magic and calculate the Unix scheduler priorities
- -// sched_policy is IN/OUT: it must be set to a valid policy before calling this function
- -// sched_priority is OUT only
- -static bool calculateUnixPriority(int priority, int *sched_policy, int *sched_priority)
- -{
- -#ifdef Q_OS_QNX
- - // without Round Robin drawn intensive apps will hog the cpu
- - // and make the system appear frozen
- - *sched_policy = SCHED_RR;
- -#endif
- -#ifdef SCHED_IDLE
- - if (priority == QThread::IdlePriority) {
- - *sched_policy = SCHED_IDLE;
- - *sched_priority = 0;
- - return true;
- - }
- - const int lowestPriority = QThread::LowestPriority;
- -#else
- - const int lowestPriority = QThread::IdlePriority;
- -#endif
- - const int highestPriority = QThread::TimeCriticalPriority;
- -
- - int prio_min = sched_get_priority_min(*sched_policy);
- - int prio_max = sched_get_priority_max(*sched_policy);
- - if (prio_min == -1 || prio_max == -1)
- - return false;
- -
- - int prio;
- - // crudely scale our priority enum values to the prio_min/prio_max
- - prio = ((priority - lowestPriority) * (prio_max - prio_min) / highestPriority) + prio_min;
- - prio = qMax(prio_min, qMin(prio_max, prio));
- -
- - *sched_priority = prio;
- - return true;
- -}
- -#endif
- -
- void QThread::start(Priority priority)
- {
- Q_D(QThread);
- QMutexLocker locker(&d->mutex);
- -
- - if (d->isInFinish)
- - d->thread_done.wait(locker.mutex());
- -
- if (d->running)
- return;
- d->running = true;
- d->finished = false;
- d->terminated = false;
- - d->returnCode = 0;
- - d->exited = false;
- pthread_attr_t attr;
- pthread_attr_init(&attr);
- @@ -574,7 +455,8 @@
- d->priority = priority;
- -#if defined(QT_HAS_THREAD_PRIORITY_SCHEDULING)
- +#if defined(Q_OS_DARWIN) || !defined(Q_OS_OPENBSD) && !defined(Q_OS_SYMBIAN) && defined(_POSIX_THREAD_PRIORITY_SCHEDULING) && (_POSIX_THREAD_PRIORITY_SCHEDULING-0 >= 0)
- +// ### Need to implement thread sheduling and priorities for symbian os. Implementation removed for now
- switch (priority) {
- case InheritPriority:
- {
- @@ -592,14 +474,32 @@
- break;
- }
- - int prio;
- - if (!calculateUnixPriority(priority, &sched_policy, &prio)) {
- + int prio_min = sched_get_priority_min(sched_policy);
- + int prio_max = sched_get_priority_max(sched_policy);
- + if (prio_min == -1 || prio_max == -1) {
- // failed to get the scheduling parameters, don't
- // bother setting the priority
- qWarning("QThread::start: Cannot determine scheduler priority range");
- break;
- }
- + int prio;
- + switch (priority) {
- + case IdlePriority:
- + prio = prio_min;
- + break;
- +
- + case TimeCriticalPriority:
- + prio = prio_max;
- + break;
- +
- + default:
- + // crudely scale our priority enum values to the prio_min/prio_max
- + prio = (priority * (prio_max - prio_min) / TimeCriticalPriority) + prio_min;
- + prio = qMax(prio_min, qMin(prio_max, prio));
- + break;
- + }
- +
- sched_param sp;
- sp.sched_priority = prio;
- @@ -607,15 +507,19 @@
- || pthread_attr_setschedpolicy(&attr, sched_policy) != 0
- || pthread_attr_setschedparam(&attr, &sp) != 0) {
- // could not set scheduling hints, fallback to inheriting them
- - // we'll try again from inside the thread
- pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
- - d->priority = Priority(priority | ThreadPriorityResetFlag);
- }
- break;
- }
- }
- -#endif // QT_HAS_THREAD_PRIORITY_SCHEDULING
- +#endif // _POSIX_THREAD_PRIORITY_SCHEDULING
- +#ifdef Q_OS_SYMBIAN
- + if (d->stackSize == 0)
- + // The default stack size on Symbian is very small, making even basic
- + // operations like file I/O fail, so we increase it by default.
- + d->stackSize = 0x14000; // Maximum stack size on Symbian.
- +#endif
- if (d->stackSize > 0) {
- #if defined(_POSIX_THREAD_ATTR_STACKSIZE) && (_POSIX_THREAD_ATTR_STACKSIZE-0 > 0)
- @@ -641,7 +545,9 @@
- if (code == EPERM) {
- // caller does not have permission to set the scheduling
- // parameters/policy
- +#ifndef Q_OS_SYMBIAN
- pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
- +#endif
- code =
- pthread_create(&d->thread_id, &attr, QThreadPrivate::start, this);
- }
- @@ -654,6 +560,9 @@
- d->running = false;
- d->finished = false;
- d->thread_id = 0;
- +#ifdef Q_OS_SYMBIAN
- + d->data->symbian_thread_handle.Close();
- +#endif
- }
- }
- @@ -665,6 +574,7 @@
- if (!d->thread_id)
- return;
- +#ifndef Q_OS_SYMBIAN
- int code = pthread_cancel(d->thread_id);
- if (code) {
- qWarning("QThread::start: Thread termination error: %s",
- @@ -672,6 +582,26 @@
- } else {
- d->terminated = true;
- }
- +#else
- + if (!d->running)
- + return;
- + if (!d->terminationEnabled) {
- + d->terminatePending = true;
- + return;
- + }
- +
- + d->terminated = true;
- + // "false, false" meaning:
- + // 1. lockAnyway = false. Don't lock the mutex because it's already locked
- + // (see above).
- + // 2. closeNativeSymbianHandle = false. We don't want to close the thread handle,
- + // because we need it here to terminate the thread.
- + QThreadPrivate::finish(this, false, false);
- + d->data->symbian_thread_handle.Terminate(KErrNone);
- + d->data->symbian_thread_handle.Close();
- +#endif
- +
- +
- }
- bool QThread::wait(unsigned long time)
- @@ -699,11 +629,25 @@
- QThread *thr = currentThread();
- Q_ASSERT_X(thr != 0, "QThread::setTerminationEnabled()",
- "Current thread was not started with QThread.");
- -
- +#ifndef Q_OS_SYMBIAN
- Q_UNUSED(thr)
- pthread_setcancelstate(enabled ? PTHREAD_CANCEL_ENABLE : PTHREAD_CANCEL_DISABLE, NULL);
- if (enabled)
- pthread_testcancel();
- +#else
- + QThreadPrivate *d = thr->d_func();
- + QMutexLocker locker(&d->mutex);
- + d->terminationEnabled = enabled;
- + if (enabled && d->terminatePending) {
- + d->terminated = true;
- + // "false" meaning:
- + // - lockAnyway = false. Don't lock the mutex because it's already locked
- + // (see above).
- + QThreadPrivate::finish(thr, false);
- + locker.unlock(); // don't leave the mutex locked!
- + pthread_exit(NULL);
- + }
- +#endif
- }
- void QThread::setPriority(Priority priority)
- @@ -719,7 +663,7 @@
- // copied from start() with a few modifications:
- -#ifdef QT_HAS_THREAD_PRIORITY_SCHEDULING
- +#if defined(Q_OS_DARWIN) || !defined(Q_OS_OPENBSD) && defined(_POSIX_THREAD_PRIORITY_SCHEDULING) && (_POSIX_THREAD_PRIORITY_SCHEDULING-0 >= 0)
- int sched_policy;
- sched_param param;
- @@ -730,28 +674,38 @@
- return;
- }
- - int prio;
- - if (!calculateUnixPriority(priority, &sched_policy, &prio)) {
- + int prio_min = sched_get_priority_min(sched_policy);
- + int prio_max = sched_get_priority_max(sched_policy);
- + if (prio_min == -1 || prio_max == -1) {
- // failed to get the scheduling parameters, don't
- // bother setting the priority
- qWarning("QThread::setPriority: Cannot determine scheduler priority range");
- return;
- }
- - param.sched_priority = prio;
- - int status = pthread_setschedparam(d->thread_id, sched_policy, ¶m);
- + int prio;
- + switch (priority) {
- + case InheritPriority:
- + qWarning("QThread::setPriority: Argument cannot be InheritPriority");
- + return;
- -# ifdef SCHED_IDLE
- - // were we trying to set to idle priority and failed?
- - if (status == -1 && sched_policy == SCHED_IDLE && errno == EINVAL) {
- - // reset to lowest priority possible
- - pthread_getschedparam(d->thread_id, &sched_policy, ¶m);
- - param.sched_priority = sched_get_priority_min(sched_policy);
- - pthread_setschedparam(d->thread_id, sched_policy, ¶m);
- + case IdlePriority:
- + prio = prio_min;
- + break;
- +
- + case TimeCriticalPriority:
- + prio = prio_max;
- + break;
- +
- + default:
- + // crudely scale our priority enum values to the prio_min/prio_max
- + prio = (priority * (prio_max - prio_min) / TimeCriticalPriority) + prio_min;
- + prio = qMax(prio_min, qMin(prio_max, prio));
- + break;
- }
- -# else
- - Q_UNUSED(status);
- -# endif // SCHED_IDLE
- +
- + param.sched_priority = prio;
- + pthread_setschedparam(d->thread_id, sched_policy, ¶m);
- #endif
- }
- diff -Naurb ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qthread_win.cpp ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qthread_win.cpp
- --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qthread_win.cpp 2012-11-23 14:09:55.000000000 +0400
- +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qthread_win.cpp 2011-06-23 11:45:00.000000000 +0400
- @@ -1,18 +1,17 @@
- /****************************************************************************
- **
- -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
- -** Contact: http://www.qt-project.org/legal
- +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
- +** All rights reserved.
- +** Contact: Nokia Corporation (qt-info@nokia.com)
- **
- ** This file is part of the QtCore module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
- -** Commercial License Usage
- -** Licensees holding valid commercial Qt licenses may use this file in
- -** accordance with the commercial license agreement provided with the
- +** Commercial Usage
- +** Licensees holding valid Qt Commercial licenses may use this file in
- +** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- -** a written agreement between you and Digia. For licensing terms and
- -** conditions see http://qt.digia.com/licensing. For further information
- -** use the contact form at http://qt.digia.com/contact-us.
- +** a written agreement between you and Nokia.
- **
- ** GNU Lesser General Public License Usage
- ** Alternatively, this file may be used under the terms of the GNU Lesser
- @@ -22,8 +21,8 @@
- ** ensure the GNU Lesser General Public License version 2.1 requirements
- ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- **
- -** In addition, as a special exception, Digia gives you certain additional
- -** rights. These rights are described in the Digia Qt LGPL Exception
- +** In addition, as a special exception, Nokia gives you certain additional
- +** rights. These rights are described in the Nokia Qt LGPL Exception
- ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- **
- ** GNU General Public License Usage
- @@ -34,7 +33,8 @@
- ** ensure the GNU General Public License version 3.0 requirements will be
- ** met: http://www.gnu.org/copyleft/gpl.html.
- **
- -**
- +** If you have questions regarding the use of this file, please contact
- +** Nokia at qt-info@nokia.com.
- ** $QT_END_LICENSE$
- **
- ****************************************************************************/
- @@ -72,7 +72,7 @@
- QT_BEGIN_NAMESPACE
- void qt_watch_adopted_thread(const HANDLE adoptedThreadHandle, QThread *qthread);
- -DWORD WINAPI qt_adopted_thread_watcher_function(LPVOID);
- +void qt_adopted_thread_watcher_function(void *);
- static DWORD qt_current_thread_data_tls_index = TLS_OUT_OF_INDEXES;
- void qt_create_tls()
- @@ -124,8 +124,6 @@
- }
- threadData->deref();
- }
- - threadData->isAdopted = true;
- - threadData->threadId = (Qt::HANDLE)GetCurrentThreadId();
- if (!QCoreApplicationPrivate::theMainThread) {
- QCoreApplicationPrivate::theMainThread = threadData->thread;
- @@ -157,7 +155,7 @@
- static QVector<HANDLE> qt_adopted_thread_handles;
- static QVector<QThread *> qt_adopted_qthreads;
- static QMutex qt_adopted_thread_watcher_mutex;
- -static DWORD qt_adopted_thread_watcher_id = 0;
- +static HANDLE qt_adopted_thread_watcher_handle = 0;
- static HANDLE qt_adopted_thread_wakeup = 0;
- /*! \internal
- @@ -168,25 +166,18 @@
- void qt_watch_adopted_thread(const HANDLE adoptedThreadHandle, QThread *qthread)
- {
- QMutexLocker lock(&qt_adopted_thread_watcher_mutex);
- -
- - if (GetCurrentThreadId() == qt_adopted_thread_watcher_id) {
- -#if !defined(Q_OS_WINCE) || (defined(_WIN32_WCE) && (_WIN32_WCE>=0x600))
- - CloseHandle(adoptedThreadHandle);
- -#endif
- - return;
- - }
- -
- qt_adopted_thread_handles.append(adoptedThreadHandle);
- qt_adopted_qthreads.append(qthread);
- // Start watcher thread if it is not already running.
- - if (qt_adopted_thread_watcher_id == 0) {
- + if (qt_adopted_thread_watcher_handle == 0) {
- if (qt_adopted_thread_wakeup == 0) {
- qt_adopted_thread_wakeup = CreateEvent(0, false, false, 0);
- qt_adopted_thread_handles.prepend(qt_adopted_thread_wakeup);
- }
- - CreateThread(0, 0, qt_adopted_thread_watcher_function, 0, 0, &qt_adopted_thread_watcher_id);
- + qt_adopted_thread_watcher_handle =
- + (HANDLE)_beginthread(qt_adopted_thread_watcher_function, 0, NULL);
- } else {
- SetEvent(qt_adopted_thread_wakeup);
- }
- @@ -197,13 +188,13 @@
- When this happens it derefs the QThreadData for the adopted thread
- to make sure it gets cleaned up properly.
- */
- -DWORD WINAPI qt_adopted_thread_watcher_function(LPVOID)
- +void qt_adopted_thread_watcher_function(void *)
- {
- forever {
- qt_adopted_thread_watcher_mutex.lock();
- if (qt_adopted_thread_handles.count() == 1) {
- - qt_adopted_thread_watcher_id = 0;
- + qt_adopted_thread_watcher_handle = 0;
- qt_adopted_thread_watcher_mutex.unlock();
- break;
- }
- @@ -228,7 +219,7 @@
- } while (ret == WAIT_TIMEOUT);
- }
- - if (ret == WAIT_FAILED || ret >= WAIT_OBJECT_0 + uint(count)) {
- + if (ret == WAIT_FAILED || !(ret >= WAIT_OBJECT_0 && ret < WAIT_OBJECT_0 + uint(count))) {
- qWarning("QThread internal error while waiting for adopted threads: %d", int(GetLastError()));
- continue;
- }
- @@ -240,33 +231,15 @@
- } else {
- // printf("(qt) - qt_adopted_thread_watcher_function... called\n");
- const int qthreadIndex = handleIndex - 1;
- -
- - qt_adopted_thread_watcher_mutex.lock();
- - QThreadData *data = QThreadData::get2(qt_adopted_qthreads.at(qthreadIndex));
- - qt_adopted_thread_watcher_mutex.unlock();
- - if (data->isAdopted) {
- - QThread *thread = data->thread;
- - Q_ASSERT(thread);
- - QThreadPrivate *thread_p = static_cast<QThreadPrivate *>(QObjectPrivate::get(thread));
- - Q_ASSERT(!thread_p->finished);
- - thread_p->finish(thread);
- - }
- - data->deref();
- -
- - QMutexLocker lock(&qt_adopted_thread_watcher_mutex);
- + QThreadData::get2(qt_adopted_qthreads.at(qthreadIndex))->deref();
- #if !defined(Q_OS_WINCE) || (defined(_WIN32_WCE) && (_WIN32_WCE>=0x600))
- CloseHandle(qt_adopted_thread_handles.at(handleIndex));
- #endif
- + QMutexLocker lock(&qt_adopted_thread_watcher_mutex);
- qt_adopted_thread_handles.remove(handleIndex);
- qt_adopted_qthreads.remove(qthreadIndex);
- }
- }
- -
- - QThreadData *threadData = reinterpret_cast<QThreadData *>(TlsGetValue(qt_current_thread_data_tls_index));
- - if (threadData)
- - threadData->deref();
- -
- - return 0;
- }
- #if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINCE)
- @@ -315,21 +288,17 @@
- #ifndef QT_NO_THREAD
- -unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(void *arg)
- +unsigned int __stdcall QThreadPrivate::start(void *arg)
- {
- QThread *thr = reinterpret_cast<QThread *>(arg);
- QThreadData *data = QThreadData::get2(thr);
- qt_create_tls();
- TlsSetValue(qt_current_thread_data_tls_index, data);
- - data->threadId = (Qt::HANDLE)GetCurrentThreadId();
- QThread::setTerminationEnabled(false);
- - {
- - QMutexLocker locker(&thr->d_func()->mutex);
- - data->quitNow = thr->d_func()->exited;
- - }
- + data->quitNow = false;
- // ### TODO: allow the user to create a custom event dispatcher
- createEventDispatcher(data);
- @@ -354,33 +323,24 @@
- QThread *thr = reinterpret_cast<QThread *>(arg);
- QThreadPrivate *d = thr->d_func();
- - QMutexLocker locker(lockAnyway ? &d->mutex : 0);
- - d->isInFinish = true;
- + if (lockAnyway)
- + d->mutex.lock();
- d->priority = QThread::InheritPriority;
- - bool terminated = d->terminated;
- - void **tls_data = reinterpret_cast<void **>(&d->data->tls);
- - locker.unlock();
- - if (terminated)
- + d->running = false;
- + d->finished = true;
- + if (d->terminated)
- emit thr->terminated();
- - emit thr->finished();
- - QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- - QThreadStorageData::finish(tls_data);
- - locker.relock();
- -
- d->terminated = false;
- + emit thr->finished();
- + if (d->data->eventDispatcher) {
- + d->data->eventDispatcher->closingDown();
- QAbstractEventDispatcher *eventDispatcher = d->data->eventDispatcher;
- - if (eventDispatcher) {
- d->data->eventDispatcher = 0;
- - locker.unlock();
- - eventDispatcher->closingDown();
- delete eventDispatcher;
- - locker.relock();
- }
- - d->running = false;
- - d->finished = true;
- - d->isInFinish = false;
- + QThreadStorageData::finish(reinterpret_cast<void **>(&d->data->tls));
- if (!d->waiters) {
- CloseHandle(d->handle);
- @@ -389,6 +349,8 @@
- d->id = 0;
- + if (lockAnyway)
- + d->mutex.unlock();
- }
- /**************************************************************************
- @@ -437,20 +399,12 @@
- Q_D(QThread);
- QMutexLocker locker(&d->mutex);
- - if (d->isInFinish) {
- - locker.unlock();
- - wait();
- - locker.relock();
- - }
- -
- if (d->running)
- return;
- d->running = true;
- d->finished = false;
- d->terminated = false;
- - d->exited = false;
- - d->returnCode = 0;
- /*
- NOTE: we create the thread in the suspended state, set the
- diff -Naurb ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qwaitcondition.h ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qwaitcondition.h
- --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qwaitcondition.h 2012-11-23 14:09:55.000000000 +0400
- +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qwaitcondition.h 2011-06-23 11:45:00.000000000 +0400
- @@ -1,18 +1,17 @@
- /****************************************************************************
- **
- -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
- -** Contact: http://www.qt-project.org/legal
- +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
- +** All rights reserved.
- +** Contact: Nokia Corporation (qt-info@nokia.com)
- **
- ** This file is part of the QtCore module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
- -** Commercial License Usage
- -** Licensees holding valid commercial Qt licenses may use this file in
- -** accordance with the commercial license agreement provided with the
- +** Commercial Usage
- +** Licensees holding valid Qt Commercial licenses may use this file in
- +** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- -** a written agreement between you and Digia. For licensing terms and
- -** conditions see http://qt.digia.com/licensing. For further information
- -** use the contact form at http://qt.digia.com/contact-us.
- +** a written agreement between you and Nokia.
- **
- ** GNU Lesser General Public License Usage
- ** Alternatively, this file may be used under the terms of the GNU Lesser
- @@ -22,8 +21,8 @@
- ** ensure the GNU Lesser General Public License version 2.1 requirements
- ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- **
- -** In addition, as a special exception, Digia gives you certain additional
- -** rights. These rights are described in the Digia Qt LGPL Exception
- +** In addition, as a special exception, Nokia gives you certain additional
- +** rights. These rights are described in the Nokia Qt LGPL Exception
- ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- **
- ** GNU General Public License Usage
- @@ -34,7 +33,8 @@
- ** ensure the GNU General Public License version 3.0 requirements will be
- ** met: http://www.gnu.org/copyleft/gpl.html.
- **
- -**
- +** If you have questions regarding the use of this file, please contact
- +** Nokia at qt-info@nokia.com.
- ** $QT_END_LICENSE$
- **
- ****************************************************************************/
- diff -Naurb ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qwaitcondition.qdoc ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qwaitcondition.qdoc
- --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qwaitcondition.qdoc 2012-11-23 14:09:55.000000000 +0400
- +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qwaitcondition.qdoc 2011-06-23 11:45:00.000000000 +0400
- @@ -1,26 +1,40 @@
- /****************************************************************************
- **
- -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
- -** Contact: http://www.qt-project.org/legal
- +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
- +** All rights reserved.
- +** Contact: Nokia Corporation (qt-info@nokia.com)
- **
- ** This file is part of the documentation of the Qt Toolkit.
- **
- -** $QT_BEGIN_LICENSE:FDL$
- -** Commercial License Usage
- -** Licensees holding valid commercial Qt licenses may use this file in
- -** accordance with the commercial license agreement provided with the
- +** $QT_BEGIN_LICENSE:LGPL$
- +** Commercial Usage
- +** Licensees holding valid Qt Commercial licenses may use this file in
- +** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- -** a written agreement between you and Digia. For licensing terms and
- -** conditions see http://qt.digia.com/licensing. For further information
- -** use the contact form at http://qt.digia.com/contact-us.
- -**
- -** GNU Free Documentation License Usage
- -** Alternatively, this file may be used under the terms of the GNU Free
- -** Documentation License version 1.3 as published by the Free Software
- -** Foundation and appearing in the file included in the packaging of
- -** this file. Please review the following information to ensure
- -** the GNU Free Documentation License version 1.3 requirements
- -** will be met: http://www.gnu.org/copyleft/fdl.html.
- +** a written agreement between you and Nokia.
- +**
- +** GNU Lesser General Public License Usage
- +** Alternatively, this file may be used under the terms of the GNU Lesser
- +** General Public License version 2.1 as published by the Free Software
- +** Foundation and appearing in the file LICENSE.LGPL included in the
- +** packaging of this file. Please review the following information to
- +** ensure the GNU Lesser General Public License version 2.1 requirements
- +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- +**
- +** In addition, as a special exception, Nokia gives you certain additional
- +** rights. These rights are described in the Nokia Qt LGPL Exception
- +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- +**
- +** GNU General Public License Usage
- +** Alternatively, this file may be used under the terms of the GNU
- +** General Public License version 3.0 as published by the Free Software
- +** Foundation and appearing in the file LICENSE.GPL included in the
- +** packaging of this file. Please review the following information to
- +** ensure the GNU General Public License version 3.0 requirements will be
- +** met: http://www.gnu.org/copyleft/gpl.html.
- +**
- +** If you have questions regarding the use of this file, please contact
- +** Nokia at qt-info@nokia.com.
- ** $QT_END_LICENSE$
- **
- ****************************************************************************/
- diff -Naurb ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qwaitcondition_symbian.cpp ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qwaitcondition_symbian.cpp
- --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qwaitcondition_symbian.cpp 2012-11-23 14:09:55.000000000 +0400
- +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qwaitcondition_symbian.cpp 1970-01-01 03:00:00.000000000 +0300
- @@ -1,199 +0,0 @@
- -/****************************************************************************
- -**
- -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
- -** Contact: http://www.qt-project.org/legal
- -**
- -** This file is part of the QtCore module of the Qt Toolkit.
- -**
- -** $QT_BEGIN_LICENSE:LGPL$
- -** Commercial License Usage
- -** Licensees holding valid commercial Qt licenses may use this file in
- -** accordance with the commercial license agreement provided with the
- -** Software or, alternatively, in accordance with the terms contained in
- -** a written agreement between you and Digia. For licensing terms and
- -** conditions see http://qt.digia.com/licensing. For further information
- -** use the contact form at http://qt.digia.com/contact-us.
- -**
- -** GNU Lesser General Public License Usage
- -** Alternatively, this file may be used under the terms of the GNU Lesser
- -** General Public License version 2.1 as published by the Free Software
- -** Foundation and appearing in the file LICENSE.LGPL included in the
- -** packaging of this file. Please review the following information to
- -** ensure the GNU Lesser General Public License version 2.1 requirements
- -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- -**
- -** In addition, as a special exception, Digia gives you certain additional
- -** rights. These rights are described in the Digia Qt LGPL Exception
- -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- -**
- -** GNU General Public License Usage
- -** Alternatively, this file may be used under the terms of the GNU
- -** General Public License version 3.0 as published by the Free Software
- -** Foundation and appearing in the file LICENSE.GPL included in the
- -** packaging of this file. Please review the following information to
- -** ensure the GNU General Public License version 3.0 requirements will be
- -** met: http://www.gnu.org/copyleft/gpl.html.
- -**
- -**
- -** $QT_END_LICENSE$
- -**
- -****************************************************************************/
- -
- -#include "qplatformdefs.h"
- -#include "qwaitcondition.h"
- -#include "qmutex.h"
- -#include "qreadwritelock.h"
- -#include "qatomic.h"
- -#include "qstring.h"
- -#include "qelapsedtimer.h"
- -
- -#include "qmutex_p.h"
- -#include "qreadwritelock_p.h"
- -
- -#ifndef QT_NO_THREAD
- -
- -QT_BEGIN_NAMESPACE
- -
- -static void report_error(int err, const char *where, const char *what)
- -{
- - if (err != KErrNone)
- - qWarning("%s: %s failure: %d", where, what, err);
- -}
- -
- -class QWaitConditionPrivate {
- -public:
- - RMutex mutex;
- - RCondVar cond;
- - int waiters;
- - int wakeups;
- -
- - QWaitConditionPrivate()
- - : waiters(0), wakeups(0)
- - {
- - qt_symbian_throwIfError(mutex.CreateLocal());
- - int err = cond.CreateLocal();
- - if (err != KErrNone) {
- - mutex.Close();
- - qt_symbian_throwIfError(err);
- - }
- - }
- -
- - ~QWaitConditionPrivate()
- - {
- - cond.Close();
- - mutex.Close();
- - }
- -
- - bool wait(unsigned long time)
- - {
- - TInt err = KErrNone;
- - if (time == ULONG_MAX) {
- - // untimed wait, loop because RCondVar::Wait may return before the condition is triggered
- - do {
- - err = cond.Wait(mutex);
- - } while (err == KErrNone && wakeups == 0);
- - } else {
- - unsigned long maxWait = KMaxTInt / 1000;
- - QElapsedTimer waitTimer;
- - do {
- - waitTimer.start();
- - unsigned long waitTime = qMin(maxWait, time);
- - // wait at least 1ms, as 0 means no wait
- - err = cond.TimedWait(mutex, qMax(1ul, waitTime) * 1000);
- - // RCondVar::TimedWait may return before the condition is triggered, update the timeout with actual wait time
- - time -= qMin((unsigned long)waitTimer.elapsed(), waitTime);
- - } while ((err == KErrNone && wakeups == 0) || (err == KErrTimedOut && time > 0));
- - }
- -
- - Q_ASSERT_X(waiters > 0, "QWaitCondition::wait", "internal error (waiters)");
- - --waiters;
- - if (err == KErrNone) {
- - Q_ASSERT_X(wakeups > 0, "QWaitCondition::wait", "internal error (wakeups)");
- - --wakeups;
- - }
- -
- - // if err is KErrGeneral it signals that the RCondVar is closed along with the mutex and that this has been deleted
- - // we must not access any member variables in this case
- - if (err != KErrGeneral)
- - mutex.Signal();
- -
- - if (err && err != KErrTimedOut)
- - report_error(err, "QWaitCondition::wait()", "cv wait");
- - return err == KErrNone;
- - }
- -};
- -
- -QWaitCondition::QWaitCondition()
- -{
- - d = new QWaitConditionPrivate;
- -}
- -
- -QWaitCondition::~QWaitCondition()
- -{
- - delete d;
- -}
- -
- -void QWaitCondition::wakeOne()
- -{
- - d->mutex.Wait();
- - d->wakeups = qMin(d->wakeups + 1, d->waiters);
- - d->cond.Signal();
- - d->mutex.Signal();
- -}
- -
- -void QWaitCondition::wakeAll()
- -{
- - d->mutex.Wait();
- - d->wakeups = d->waiters;
- - d->cond.Broadcast();
- - d->mutex.Signal();
- -}
- -
- -bool QWaitCondition::wait(QMutex *mutex, unsigned long time)
- -{
- - if (! mutex)
- - return false;
- - if (mutex->d->recursive) {
- - qWarning("QWaitCondition: cannot wait on recursive mutexes");
- - return false;
- - }
- -
- - d->mutex.Wait();
- - ++d->waiters;
- - mutex->unlock();
- -
- - bool returnValue = d->wait(time);
- -
- - mutex->lock();
- -
- - return returnValue;
- -}
- -
- -bool QWaitCondition::wait(QReadWriteLock *readWriteLock, unsigned long time)
- -{
- - if (!readWriteLock || readWriteLock->d->accessCount == 0)
- - return false;
- - if (readWriteLock->d->accessCount < -1) {
- - qWarning("QWaitCondition: cannot wait on QReadWriteLocks with recursive lockForWrite()");
- - return false;
- - }
- -
- - d->mutex.Wait();
- - ++d->waiters;
- -
- - int previousAccessCount = readWriteLock->d->accessCount;
- - readWriteLock->unlock();
- -
- - bool returnValue = d->wait(time);
- -
- - if (previousAccessCount < 0)
- - readWriteLock->lockForWrite();
- - else
- - readWriteLock->lockForRead();
- -
- - return returnValue;
- -}
- -
- -QT_END_NAMESPACE
- -
- -#endif // QT_NO_THREAD
- diff -Naurb ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qwaitcondition_unix.cpp ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qwaitcondition_unix.cpp
- --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qwaitcondition_unix.cpp 2012-11-23 14:09:55.000000000 +0400
- +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qwaitcondition_unix.cpp 2011-06-23 11:45:00.000000000 +0400
- @@ -1,18 +1,17 @@
- /****************************************************************************
- **
- -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
- -** Contact: http://www.qt-project.org/legal
- +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
- +** All rights reserved.
- +** Contact: Nokia Corporation (qt-info@nokia.com)
- **
- ** This file is part of the QtCore module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
- -** Commercial License Usage
- -** Licensees holding valid commercial Qt licenses may use this file in
- -** accordance with the commercial license agreement provided with the
- +** Commercial Usage
- +** Licensees holding valid Qt Commercial licenses may use this file in
- +** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- -** a written agreement between you and Digia. For licensing terms and
- -** conditions see http://qt.digia.com/licensing. For further information
- -** use the contact form at http://qt.digia.com/contact-us.
- +** a written agreement between you and Nokia.
- **
- ** GNU Lesser General Public License Usage
- ** Alternatively, this file may be used under the terms of the GNU Lesser
- @@ -22,8 +21,8 @@
- ** ensure the GNU Lesser General Public License version 2.1 requirements
- ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- **
- -** In addition, as a special exception, Digia gives you certain additional
- -** rights. These rights are described in the Digia Qt LGPL Exception
- +** In addition, as a special exception, Nokia gives you certain additional
- +** rights. These rights are described in the Nokia Qt LGPL Exception
- ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- **
- ** GNU General Public License Usage
- @@ -34,7 +33,8 @@
- ** ensure the GNU General Public License version 3.0 requirements will be
- ** met: http://www.gnu.org/copyleft/gpl.html.
- **
- -**
- +** If you have questions regarding the use of this file, please contact
- +** Nokia at qt-info@nokia.com.
- ** $QT_END_LICENSE$
- **
- ****************************************************************************/
- @@ -61,8 +61,9 @@
- qWarning("%s: %s failure: %s", where, what, qPrintable(qt_error_string(code)));
- }
- -class QWaitConditionPrivate {
- -public:
- +
- +
- +struct QWaitConditionPrivate {
- pthread_mutex_t mutex;
- pthread_cond_t cond;
- int waiters;
- diff -Naurb ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qwaitcondition_win.cpp ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qwaitcondition_win.cpp
- --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qwaitcondition_win.cpp 2012-11-23 14:09:55.000000000 +0400
- +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qwaitcondition_win.cpp 2011-06-23 11:45:00.000000000 +0400
- @@ -1,18 +1,17 @@
- /****************************************************************************
- **
- -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
- -** Contact: http://www.qt-project.org/legal
- +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
- +** All rights reserved.
- +** Contact: Nokia Corporation (qt-info@nokia.com)
- **
- ** This file is part of the QtCore module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
- -** Commercial License Usage
- -** Licensees holding valid commercial Qt licenses may use this file in
- -** accordance with the commercial license agreement provided with the
- +** Commercial Usage
- +** Licensees holding valid Qt Commercial licenses may use this file in
- +** accordance with the Qt Commercial License Agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- -** a written agreement between you and Digia. For licensing terms and
- -** conditions see http://qt.digia.com/licensing. For further information
- -** use the contact form at http://qt.digia.com/contact-us.
- +** a written agreement between you and Nokia.
- **
- ** GNU Lesser General Public License Usage
- ** Alternatively, this file may be used under the terms of the GNU Lesser
- @@ -22,8 +21,8 @@
- ** ensure the GNU Lesser General Public License version 2.1 requirements
- ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- **
- -** In addition, as a special exception, Digia gives you certain additional
- -** rights. These rights are described in the Digia Qt LGPL Exception
- +** In addition, as a special exception, Nokia gives you certain additional
- +** rights. These rights are described in the Nokia Qt LGPL Exception
- ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- **
- ** GNU General Public License Usage
- @@ -34,7 +33,8 @@
- ** ensure the GNU General Public License version 3.0 requirements will be
- ** met: http://www.gnu.org/copyleft/gpl.html.
- **
- -**
- +** If you have questions regarding the use of this file, please contact
- +** Nokia at qt-info@nokia.com.
- ** $QT_END_LICENSE$
- **
- ****************************************************************************/
- diff -Naurb ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/thread.pri ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/thread.pri
- --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/thread.pri 2012-11-23 14:09:55.000000000 +0400
- +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/thread.pri 2011-06-23 11:45:00.000000000 +0400
- @@ -24,18 +24,10 @@
- thread/qthread.cpp \
- thread/qthreadstorage.cpp
- -unix:!symbian:SOURCES += thread/qmutex_unix.cpp \
- +unix:SOURCES += thread/qmutex_unix.cpp \
- thread/qthread_unix.cpp \
- thread/qwaitcondition_unix.cpp
- -symbian:SOURCES += thread/qmutex_symbian.cpp \
- - thread/qthread_symbian.cpp \
- - thread/qwaitcondition_symbian.cpp
- -
- win32:SOURCES += thread/qmutex_win.cpp \
- thread/qthread_win.cpp \
- thread/qwaitcondition_win.cpp
- -
- -integrity:SOURCES += thread/qmutex_unix.cpp \
- - thread/qthread_unix.cpp \
- - thread/qwaitcondition_unix.cpp
Add Comment
Please, Sign In to add comment