Guest User

adopt-for-kernel24.patch

a guest
Feb 15th, 2013
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 181.33 KB | None | 0 0
  1. 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
  2. --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/plugin/quuid.cpp   2012-11-23 14:09:55.000000000 +0400
  3. +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/plugin/quuid.cpp   2013-02-14 19:42:00.000000000 +0400
  4. @@ -105,6 +105,43 @@
  5.      *dst = Char('}');
  6.  }
  7.  
  8. +
  9. +void _q_uuidToHex(char *&dst, const uint &d1, const ushort &d2, const ushort &d3, const uchar (&d4)[8])
  10. +{
  11. +    *dst++ = char('{');
  12. +    _q_toHex(dst, d1);
  13. +    *dst++ = char('-');
  14. +    _q_toHex(dst, d2);
  15. +    *dst++ = char('-');
  16. +    _q_toHex(dst, d3);
  17. +    *dst++ = char('-');
  18. +    for (int i = 0; i < 2; i++)
  19. +        _q_toHex(dst, d4[i]);
  20. +    *dst++ = char('-');
  21. +    for (int i = 2; i < 8; i++)
  22. +        _q_toHex(dst, d4[i]);
  23. +    *dst = char('}');
  24. +}
  25. +
  26. +
  27. +void _q_uuidToHex(ushort *&dst, const uint &d1, const ushort &d2, const ushort &d3, const uchar (&d4)[8])
  28. +{
  29. +    *dst++ = ushort('{');
  30. +    _q_toHex(dst, d1);
  31. +    *dst++ = ushort('-');
  32. +    _q_toHex(dst, d2);
  33. +    *dst++ = ushort('-');
  34. +    _q_toHex(dst, d3);
  35. +    *dst++ = ushort('-');
  36. +    for (int i = 0; i < 2; i++)
  37. +        _q_toHex(dst, d4[i]);
  38. +    *dst++ = ushort('-');
  39. +    for (int i = 2; i < 8; i++)
  40. +        _q_toHex(dst, d4[i]);
  41. +    *dst = ushort('}');
  42. +}
  43. +
  44. +
  45.  template <class Char>
  46.  bool _q_uuidFromHex(const Char *&src, uint &d1, ushort &d2, ushort &d3, uchar (&d4)[8])
  47.  {
  48. @@ -130,6 +167,59 @@
  49.  
  50.      return true;
  51.  }
  52. +
  53. +
  54. +bool _q_uuidFromHex(const char *&src, uint &d1, ushort &d2, ushort &d3, uchar (&d4)[8])
  55. +{
  56. +    if (*src == char('{'))
  57. +        src++;
  58. +    if (!_q_fromHex(src, d1)
  59. +            || *src++ != char('-')
  60. +            || !_q_fromHex(src, d2)
  61. +            || *src++ != char('-')
  62. +            || !_q_fromHex(src, d3)
  63. +            || *src++ != char('-')
  64. +            || !_q_fromHex(src, d4[0])
  65. +            || !_q_fromHex(src, d4[1])
  66. +            || *src++ != char('-')
  67. +            || !_q_fromHex(src, d4[2])
  68. +            || !_q_fromHex(src, d4[3])
  69. +            || !_q_fromHex(src, d4[4])
  70. +            || !_q_fromHex(src, d4[5])
  71. +            || !_q_fromHex(src, d4[6])
  72. +            || !_q_fromHex(src, d4[7])) {
  73. +        return false;
  74. +    }
  75. +
  76. +    return true;
  77. +}
  78. +
  79. +
  80. +bool _q_uuidFromHex(const ushort *&src, uint &d1, ushort &d2, ushort &d3, uchar (&d4)[8])
  81. +{
  82. +    if (*src == ushort('{'))
  83. +        src++;
  84. +    if (!_q_fromHex(src, d1)
  85. +            || *src++ != ushort('-')
  86. +            || !_q_fromHex(src, d2)
  87. +            || *src++ != ushort('-')
  88. +            || !_q_fromHex(src, d3)
  89. +            || *src++ != ushort('-')
  90. +            || !_q_fromHex(src, d4[0])
  91. +            || !_q_fromHex(src, d4[1])
  92. +            || *src++ != ushort('-')
  93. +            || !_q_fromHex(src, d4[2])
  94. +            || !_q_fromHex(src, d4[3])
  95. +            || !_q_fromHex(src, d4[4])
  96. +            || !_q_fromHex(src, d4[5])
  97. +            || !_q_fromHex(src, d4[6])
  98. +            || !_q_fromHex(src, d4[7])) {
  99. +        return false;
  100. +    }
  101. +
  102. +    return true;
  103. +}
  104. +
  105.  #endif
  106.  
  107.  /*!
  108. 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
  109. --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qatomic.cpp 2012-11-23 14:09:55.000000000 +0400
  110. +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qatomic.cpp 2011-06-23 11:45:00.000000000 +0400
  111. @@ -1,18 +1,17 @@
  112.  /****************************************************************************
  113.  **
  114. -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
  115. -** Contact: http://www.qt-project.org/legal
  116. +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
  117. +** All rights reserved.
  118. +** Contact: Nokia Corporation (qt-info@nokia.com)
  119.  **
  120.  ** This file is part of the QtCore module of the Qt Toolkit.
  121.  **
  122.  ** $QT_BEGIN_LICENSE:LGPL$
  123. -** Commercial License Usage
  124. -** Licensees holding valid commercial Qt licenses may use this file in
  125. -** accordance with the commercial license agreement provided with the
  126. +** Commercial Usage
  127. +** Licensees holding valid Qt Commercial licenses may use this file in
  128. +** accordance with the Qt Commercial License Agreement provided with the
  129.  ** Software or, alternatively, in accordance with the terms contained in
  130. -** a written agreement between you and Digia.  For licensing terms and
  131. -** conditions see http://qt.digia.com/licensing.  For further information
  132. -** use the contact form at http://qt.digia.com/contact-us.
  133. +** a written agreement between you and Nokia.
  134.  **
  135.  ** GNU Lesser General Public License Usage
  136.  ** Alternatively, this file may be used under the terms of the GNU Lesser
  137. @@ -22,8 +21,8 @@
  138.  ** ensure the GNU Lesser General Public License version 2.1 requirements
  139.  ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  140.  **
  141. -** In addition, as a special exception, Digia gives you certain additional
  142. -** rights.  These rights are described in the Digia Qt LGPL Exception
  143. +** In addition, as a special exception, Nokia gives you certain additional
  144. +** rights.  These rights are described in the Nokia Qt LGPL Exception
  145.  ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  146.  **
  147.  ** GNU General Public License Usage
  148. @@ -34,7 +33,8 @@
  149.  ** ensure the GNU General Public License version 3.0 requirements will be
  150.  ** met: http://www.gnu.org/copyleft/gpl.html.
  151.  **
  152. -**
  153. +** If you have questions regarding the use of this file, please contact
  154. +** Nokia at qt-info@nokia.com.
  155.  ** $QT_END_LICENSE$
  156.  **
  157.  ****************************************************************************/
  158. @@ -48,9 +48,10 @@
  159.  
  160.      For atomic operations on pointers, see the QAtomicPointer class.
  161.  
  162. -    An \e atomic operation is a complex operation that completes without interruption.
  163. -    The QAtomicInt class provides atomic reference counting, test-and-set, fetch-and-store,
  164. -    and fetch-and-add for integers.
  165. +    An complex operation that completes without interruption is said
  166. +    to be \e atomic. The QAtomicInt class provides atomic reference
  167. +    counting, test-and-set, fetch-and-store, and fetch-and-add for
  168. +    integers.
  169.  
  170.      \section1 Non-atomic convenience operators
  171.  
  172. @@ -634,8 +635,9 @@
  173.  
  174.      For atomic operations on integers, see the QAtomicInt class.
  175.  
  176. -    An \e atomic operation is a complex operation that completes without interruption.
  177. -    The QAtomicPointer class provides atomic test-and-set, fetch-and-store, and fetch-and-add for pointers.
  178. +    An complex operation that completes without interruption is said
  179. +    to be \e atomic. The QAtomicPointer class provides atomic
  180. +    test-and-set, fetch-and-store, and fetch-and-add for pointers.
  181.  
  182.      \section1 Non-atomic convenience operators
  183.  
  184. 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
  185. --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qatomic.h   2012-11-23 14:09:55.000000000 +0400
  186. +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qatomic.h   2011-06-23 11:45:00.000000000 +0400
  187. @@ -1,18 +1,17 @@
  188.  /****************************************************************************
  189.  **
  190. -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
  191. -** Contact: http://www.qt-project.org/legal
  192. +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
  193. +** All rights reserved.
  194. +** Contact: Nokia Corporation (qt-info@nokia.com)
  195.  **
  196.  ** This file is part of the QtCore module of the Qt Toolkit.
  197.  **
  198.  ** $QT_BEGIN_LICENSE:LGPL$
  199. -** Commercial License Usage
  200. -** Licensees holding valid commercial Qt licenses may use this file in
  201. -** accordance with the commercial license agreement provided with the
  202. +** Commercial Usage
  203. +** Licensees holding valid Qt Commercial licenses may use this file in
  204. +** accordance with the Qt Commercial License Agreement provided with the
  205.  ** Software or, alternatively, in accordance with the terms contained in
  206. -** a written agreement between you and Digia.  For licensing terms and
  207. -** conditions see http://qt.digia.com/licensing.  For further information
  208. -** use the contact form at http://qt.digia.com/contact-us.
  209. +** a written agreement between you and Nokia.
  210.  **
  211.  ** GNU Lesser General Public License Usage
  212.  ** Alternatively, this file may be used under the terms of the GNU Lesser
  213. @@ -22,8 +21,8 @@
  214.  ** ensure the GNU Lesser General Public License version 2.1 requirements
  215.  ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  216.  **
  217. -** In addition, as a special exception, Digia gives you certain additional
  218. -** rights.  These rights are described in the Digia Qt LGPL Exception
  219. +** In addition, as a special exception, Nokia gives you certain additional
  220. +** rights.  These rights are described in the Nokia Qt LGPL Exception
  221.  ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  222.  **
  223.  ** GNU General Public License Usage
  224. @@ -34,7 +33,8 @@
  225.  ** ensure the GNU General Public License version 3.0 requirements will be
  226.  ** met: http://www.gnu.org/copyleft/gpl.html.
  227.  **
  228. -**
  229. +** If you have questions regarding the use of this file, please contact
  230. +** Nokia at qt-info@nokia.com.
  231.  ** $QT_END_LICENSE$
  232.  **
  233.  ****************************************************************************/
  234. 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
  235. --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qbasicatomic.h  2012-11-23 14:09:55.000000000 +0400
  236. +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qbasicatomic.h  2011-06-23 11:45:00.000000000 +0400
  237. @@ -1,18 +1,17 @@
  238.  /****************************************************************************
  239.  **
  240. -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
  241. -** Contact: http://www.qt-project.org/legal
  242. +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
  243. +** All rights reserved.
  244. +** Contact: Nokia Corporation (qt-info@nokia.com)
  245.  **
  246.  ** This file is part of the QtCore module of the Qt Toolkit.
  247.  **
  248.  ** $QT_BEGIN_LICENSE:LGPL$
  249. -** Commercial License Usage
  250. -** Licensees holding valid commercial Qt licenses may use this file in
  251. -** accordance with the commercial license agreement provided with the
  252. +** Commercial Usage
  253. +** Licensees holding valid Qt Commercial licenses may use this file in
  254. +** accordance with the Qt Commercial License Agreement provided with the
  255.  ** Software or, alternatively, in accordance with the terms contained in
  256. -** a written agreement between you and Digia.  For licensing terms and
  257. -** conditions see http://qt.digia.com/licensing.  For further information
  258. -** use the contact form at http://qt.digia.com/contact-us.
  259. +** a written agreement between you and Nokia.
  260.  **
  261.  ** GNU Lesser General Public License Usage
  262.  ** Alternatively, this file may be used under the terms of the GNU Lesser
  263. @@ -22,8 +21,8 @@
  264.  ** ensure the GNU Lesser General Public License version 2.1 requirements
  265.  ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  266.  **
  267. -** In addition, as a special exception, Digia gives you certain additional
  268. -** rights.  These rights are described in the Digia Qt LGPL Exception
  269. +** In addition, as a special exception, Nokia gives you certain additional
  270. +** rights.  These rights are described in the Nokia Qt LGPL Exception
  271.  ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  272.  **
  273.  ** GNU General Public License Usage
  274. @@ -34,7 +33,8 @@
  275.  ** ensure the GNU General Public License version 3.0 requirements will be
  276.  ** met: http://www.gnu.org/copyleft/gpl.html.
  277.  **
  278. -**
  279. +** If you have questions regarding the use of this file, please contact
  280. +** Nokia at qt-info@nokia.com.
  281.  ** $QT_END_LICENSE$
  282.  **
  283.  ****************************************************************************/
  284. 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
  285. --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qmutex.cpp  2012-11-23 14:09:55.000000000 +0400
  286. +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qmutex.cpp  2011-06-23 11:45:00.000000000 +0400
  287. @@ -1,18 +1,17 @@
  288.  /****************************************************************************
  289.  **
  290. -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
  291. -** Contact: http://www.qt-project.org/legal
  292. +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
  293. +** All rights reserved.
  294. +** Contact: Nokia Corporation (qt-info@nokia.com)
  295.  **
  296.  ** This file is part of the QtCore module of the Qt Toolkit.
  297.  **
  298.  ** $QT_BEGIN_LICENSE:LGPL$
  299. -** Commercial License Usage
  300. -** Licensees holding valid commercial Qt licenses may use this file in
  301. -** accordance with the commercial license agreement provided with the
  302. +** Commercial Usage
  303. +** Licensees holding valid Qt Commercial licenses may use this file in
  304. +** accordance with the Qt Commercial License Agreement provided with the
  305.  ** Software or, alternatively, in accordance with the terms contained in
  306. -** a written agreement between you and Digia.  For licensing terms and
  307. -** conditions see http://qt.digia.com/licensing.  For further information
  308. -** use the contact form at http://qt.digia.com/contact-us.
  309. +** a written agreement between you and Nokia.
  310.  **
  311.  ** GNU Lesser General Public License Usage
  312.  ** Alternatively, this file may be used under the terms of the GNU Lesser
  313. @@ -22,8 +21,8 @@
  314.  ** ensure the GNU Lesser General Public License version 2.1 requirements
  315.  ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  316.  **
  317. -** In addition, as a special exception, Digia gives you certain additional
  318. -** rights.  These rights are described in the Digia Qt LGPL Exception
  319. +** In addition, as a special exception, Nokia gives you certain additional
  320. +** rights.  These rights are described in the Nokia Qt LGPL Exception
  321.  ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  322.  **
  323.  ** GNU General Public License Usage
  324. @@ -34,18 +33,17 @@
  325.  ** ensure the GNU General Public License version 3.0 requirements will be
  326.  ** met: http://www.gnu.org/copyleft/gpl.html.
  327.  **
  328. -**
  329. +** If you have questions regarding the use of this file, please contact
  330. +** Nokia at qt-info@nokia.com.
  331.  ** $QT_END_LICENSE$
  332.  **
  333.  ****************************************************************************/
  334.  
  335.  #include "qplatformdefs.h"
  336.  #include "qmutex.h"
  337. -#include <qdebug.h>
  338.  
  339.  #ifndef QT_NO_THREAD
  340.  #include "qatomic.h"
  341. -#include "qelapsedtimer.h"
  342.  #include "qthread.h"
  343.  #include "qmutex_p.h"
  344.  
  345. @@ -131,7 +129,7 @@
  346.      \warning Destroying a locked mutex may result in undefined behavior.
  347.  */
  348.  QMutex::~QMutex()
  349. -{ delete static_cast<QMutexPrivate *>(d); }
  350. +{ delete d; }
  351.  
  352.  /*!
  353.      Locks the mutex. If another thread has locked the mutex then this
  354. @@ -147,7 +145,6 @@
  355.  */
  356.  void QMutex::lock()
  357.  {
  358. -    QMutexPrivate *d = static_cast<QMutexPrivate *>(this->d);
  359.      Qt::HANDLE self;
  360.  
  361.      if (d->recursive) {
  362. @@ -158,12 +155,21 @@
  363.              return;
  364.          }
  365.  
  366. -        bool isLocked = d->contenders.testAndSetAcquire(0, 1);
  367. +        bool isLocked = d->contenders.fetchAndAddAcquire(1) == 0;
  368.          if (!isLocked) {
  369. +#ifndef QT_NO_DEBUG
  370. +            if (d->owner == self)
  371. +                qWarning("QMutex::lock: Deadlock detected in thread %ld",
  372. +                         long(d->owner));
  373. +#endif
  374. +
  375.              // didn't get the lock, wait for it
  376.              isLocked = d->wait();
  377.              Q_ASSERT_X(isLocked, "QMutex::lock",
  378.                         "Internal error, infinite wait has timed out.");
  379. +
  380. +            // don't need to wait for the lock anymore
  381. +            d->contenders.deref();
  382.          }
  383.  
  384.          d->owner = self;
  385. @@ -172,10 +178,55 @@
  386.          return;
  387.      }
  388.  
  389. -    bool isLocked = d->contenders.testAndSetAcquire(0, 1);
  390. +#ifndef QT_NO_DEBUG
  391. +    self = QThread::currentThreadId();
  392. +#endif
  393. +
  394. +    bool isLocked = d->contenders == 0 && d->contenders.testAndSetAcquire(0, 1);
  395.      if (!isLocked) {
  396. -        lockInternal();
  397. +        int spinCount = 0;
  398. +        int lastSpinCount = d->lastSpinCount;
  399. +
  400. +        enum { AdditionalSpins = 20, SpinCountPenalizationDivisor = 4 };
  401. +        const int maximumSpinCount = lastSpinCount + AdditionalSpins;
  402. +
  403. +        do {
  404. +            if (spinCount++ > maximumSpinCount) {
  405. +                // puts("spinning useless, sleeping");
  406. +                isLocked = d->contenders.fetchAndAddAcquire(1) == 0;
  407. +                if (!isLocked) {
  408. +#ifndef QT_NO_DEBUG
  409. +                    if (d->owner == self)
  410. +                        qWarning("QMutex::lock: Deadlock detected in thread %ld",
  411. +                                 long(d->owner));
  412. +#endif
  413. +
  414. +                    // didn't get the lock, wait for it
  415. +                    isLocked = d->wait();
  416. +                    Q_ASSERT_X(isLocked, "QMutex::lock",
  417. +                               "Internal error, infinite wait has timed out.");
  418. +
  419. +                    // don't need to wait for the lock anymore
  420. +                    d->contenders.deref();
  421.      }
  422. +                // decrease the lastSpinCount since we didn't actually get the lock by spinning
  423. +                spinCount = -d->lastSpinCount / SpinCountPenalizationDivisor;
  424. +                break;
  425. +            }
  426. +
  427. +            isLocked = d->contenders == 0 && d->contenders.testAndSetAcquire(0, 1);
  428. +        } while (!isLocked);
  429. +
  430. +        // adjust the last spin lock count
  431. +        lastSpinCount = d->lastSpinCount;
  432. +        d->lastSpinCount = spinCount >= 0
  433. +                           ? qMax(lastSpinCount, spinCount)
  434. +                           : lastSpinCount + spinCount;
  435. +    }
  436. +
  437. +#ifndef QT_NO_DEBUG
  438. +    d->owner = self;
  439. +#endif
  440.  }
  441.  
  442.  /*!
  443. @@ -197,7 +248,6 @@
  444.  */
  445.  bool QMutex::tryLock()
  446.  {
  447. -    QMutexPrivate *d = static_cast<QMutexPrivate *>(this->d);
  448.      Qt::HANDLE self;
  449.  
  450.      if (d->recursive) {
  451. @@ -208,7 +258,7 @@
  452.              return true;
  453.          }
  454.  
  455. -        bool isLocked = d->contenders.testAndSetAcquire(0, 1);
  456. +        bool isLocked = d->contenders == 0 && d->contenders.testAndSetAcquire(0, 1);
  457.          if (!isLocked) {
  458.              // some other thread has the mutex locked, or we tried to
  459.              // recursively lock an non-recursive mutex
  460. @@ -221,7 +271,19 @@
  461.          return isLocked;
  462.      }
  463.  
  464. -    return d->contenders.testAndSetAcquire(0, 1);
  465. +#ifndef QT_NO_DEBUG
  466. +    self = QThread::currentThreadId();
  467. +#endif
  468. +    bool isLocked = d->contenders == 0 && d->contenders.testAndSetAcquire(0, 1);
  469. +    if (!isLocked) {
  470. +        // some other thread has the mutex locked, or we tried to
  471. +        // recursively lock an non-recursive mutex
  472. +        return isLocked;
  473. +    }
  474. +#ifndef QT_NO_DEBUG
  475. +    d->owner = self;
  476. +#endif
  477. +    return isLocked;
  478.  }
  479.  
  480.  /*! \overload
  481. @@ -249,7 +311,6 @@
  482.  */
  483.  bool QMutex::tryLock(int timeout)
  484.  {
  485. -    QMutexPrivate *d = static_cast<QMutexPrivate *>(this->d);
  486.      Qt::HANDLE self;
  487.  
  488.      if (d->recursive) {
  489. @@ -260,10 +321,13 @@
  490.              return true;
  491.          }
  492.  
  493. -        bool isLocked = d->contenders.testAndSetAcquire(0, 1);
  494. +        bool isLocked = d->contenders.fetchAndAddAcquire(1) == 0;
  495.          if (!isLocked) {
  496.              // didn't get the lock, wait for it
  497.              isLocked = d->wait(timeout);
  498. +
  499. +            // don't need to wait for the lock anymore
  500. +            d->contenders.deref();
  501.              if (!isLocked)
  502.                  return false;
  503.          }
  504. @@ -274,9 +338,23 @@
  505.          return true;
  506.      }
  507.  
  508. -    return (d->contenders.testAndSetAcquire(0, 1)
  509. +#ifndef QT_NO_DEBUG
  510. +    self = QThread::currentThreadId();
  511. +#endif
  512. +    bool isLocked = d->contenders.fetchAndAddAcquire(1) == 0;
  513. +    if (!isLocked) {
  514.              // didn't get the lock, wait for it
  515. -            || d->wait(timeout));
  516. +        isLocked = d->wait(timeout);
  517. +
  518. +        // don't need to wait for the lock anymore
  519. +        d->contenders.deref();
  520. +        if (!isLocked)
  521. +            return false;
  522. +    }
  523. +#ifndef QT_NO_DEBUG
  524. +    d->owner = self;
  525. +#endif
  526. +    return true;
  527.  }
  528.  
  529.  
  530. @@ -289,7 +367,9 @@
  531.  */
  532.  void QMutex::unlock()
  533.  {
  534. -    QMutexPrivate *d = static_cast<QMutexPrivate *>(this->d);
  535. +    Q_ASSERT_X(d->owner == QThread::currentThreadId(), "QMutex::unlock()",
  536. +               "A mutex must be unlocked in the same thread that locked it.");
  537. +
  538.      if (d->recursive) {
  539.          if (!--d->count) {
  540.              d->owner = 0;
  541. @@ -297,6 +377,9 @@
  542.                  d->wakeUp();
  543.          }
  544.      } else {
  545. +#ifndef QT_NO_DEBUG
  546. +        d->owner = 0;
  547. +#endif
  548.          if (!d->contenders.testAndSetRelease(1, 0))
  549.              d->wakeUp();
  550.      }
  551. @@ -424,92 +507,6 @@
  552.      Use the constructor that takes a RecursionMode parameter instead.
  553.  */
  554.  
  555. -/*!
  556. -    \internal helper for lockInline()
  557. - */
  558. -void QMutex::lockInternal()
  559. -{
  560. -    QMutexPrivate *d = static_cast<QMutexPrivate *>(this->d);
  561. -
  562. -    if (QThread::idealThreadCount() == 1) {
  563. -        // don't spin on single cpu machines
  564. -        bool isLocked = d->wait();
  565. -        Q_ASSERT_X(isLocked, "QMutex::lock",
  566. -                   "Internal error, infinite wait has timed out.");
  567. -        Q_UNUSED(isLocked);
  568. -        return;
  569. -    }
  570. -
  571. -    QElapsedTimer elapsedTimer;
  572. -    elapsedTimer.start();
  573. -    do {
  574. -        qint64 spinTime = elapsedTimer.nsecsElapsed();
  575. -        if (spinTime > d->maximumSpinTime) {
  576. -            // didn't get the lock, wait for it, since we're not going to gain anything by spinning more
  577. -            elapsedTimer.start();
  578. -            bool isLocked = d->wait();
  579. -            Q_ASSERT_X(isLocked, "QMutex::lock",
  580. -                       "Internal error, infinite wait has timed out.");
  581. -            Q_UNUSED(isLocked);
  582. -
  583. -            qint64 maximumSpinTime = d->maximumSpinTime;
  584. -            qint64 averageWaitTime = d->averageWaitTime;
  585. -            qint64 actualWaitTime = elapsedTimer.nsecsElapsed();
  586. -            if (actualWaitTime < (QMutexPrivate::MaximumSpinTimeThreshold * 3 / 2)) {
  587. -                // measure the wait times
  588. -                averageWaitTime = d->averageWaitTime = qMin((averageWaitTime + actualWaitTime) / 2, qint64(QMutexPrivate::MaximumSpinTimeThreshold));
  589. -            }
  590. -
  591. -            // adjust the spin count when spinning does not benefit contention performance
  592. -            if ((spinTime + actualWaitTime) - qint64(QMutexPrivate::MaximumSpinTimeThreshold) >= qint64(QMutexPrivate::MaximumSpinTimeThreshold)) {
  593. -                // long waits, stop spinning
  594. -                d->maximumSpinTime = 0;
  595. -            } else {
  596. -                // allow spinning if wait times decrease, but never spin more than the average wait time (otherwise we may perform worse)
  597. -                d->maximumSpinTime = qBound(qint64(averageWaitTime * 3 / 2), maximumSpinTime / 2, qint64(QMutexPrivate::MaximumSpinTimeThreshold));
  598. -            }
  599. -            return;
  600. -        }
  601. -        // be a good citizen... yielding lets something else run if there is something to run, but may also relieve memory pressure if not
  602. -        QThread::yieldCurrentThread();
  603. -    } while (d->contenders != 0 || !d->contenders.testAndSetAcquire(0, 1));
  604. -
  605. -    // spinning is working, do not change the spin time (unless we are using much less time than allowed to spin)
  606. -    qint64 maximumSpinTime = d->maximumSpinTime;
  607. -    qint64 spinTime = elapsedTimer.nsecsElapsed();
  608. -    if (spinTime < maximumSpinTime / 2) {
  609. -        // we are using much less time than we need, adjust the limit
  610. -        d->maximumSpinTime = qBound(qint64(d->averageWaitTime * 3 / 2), maximumSpinTime / 2, qint64(QMutexPrivate::MaximumSpinTimeThreshold));
  611. -    }
  612. -}
  613. -
  614. -/*!
  615. -    \internal
  616. -*/
  617. -void QMutex::unlockInternal()
  618. -{
  619. -    static_cast<QMutexPrivate *>(d)->wakeUp();
  620. -}
  621. -
  622. -/*!
  623. -   \fn QMutex::lockInline()
  624. -   \internal
  625. -   inline version of QMutex::lock()
  626. -*/
  627. -
  628. -/*!
  629. -   \fn QMutex::unlockInline()
  630. -   \internal
  631. -   inline version of QMutex::unlock()
  632. -*/
  633. -
  634. -/*!
  635. -   \fn QMutex::tryLockInline()
  636. -   \internal
  637. -   inline version of QMutex::tryLock()
  638. -*/
  639. -
  640. -
  641.  QT_END_NAMESPACE
  642.  
  643.  #endif // QT_NO_THREAD
  644. 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
  645. --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qmutex.h    2012-11-23 14:09:55.000000000 +0400
  646. +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qmutex.h    2013-02-14 19:57:00.000000000 +0400
  647. @@ -1,18 +1,17 @@
  648.  /****************************************************************************
  649.  **
  650. -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
  651. -** Contact: http://www.qt-project.org/legal
  652. +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
  653. +** All rights reserved.
  654. +** Contact: Nokia Corporation (qt-info@nokia.com)
  655.  **
  656.  ** This file is part of the QtCore module of the Qt Toolkit.
  657.  **
  658.  ** $QT_BEGIN_LICENSE:LGPL$
  659. -** Commercial License Usage
  660. -** Licensees holding valid commercial Qt licenses may use this file in
  661. -** accordance with the commercial license agreement provided with the
  662. +** Commercial Usage
  663. +** Licensees holding valid Qt Commercial licenses may use this file in
  664. +** accordance with the Qt Commercial License Agreement provided with the
  665.  ** Software or, alternatively, in accordance with the terms contained in
  666. -** a written agreement between you and Digia.  For licensing terms and
  667. -** conditions see http://qt.digia.com/licensing.  For further information
  668. -** use the contact form at http://qt.digia.com/contact-us.
  669. +** a written agreement between you and Nokia.
  670.  **
  671.  ** GNU Lesser General Public License Usage
  672.  ** Alternatively, this file may be used under the terms of the GNU Lesser
  673. @@ -22,8 +21,8 @@
  674.  ** ensure the GNU Lesser General Public License version 2.1 requirements
  675.  ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  676.  **
  677. -** In addition, as a special exception, Digia gives you certain additional
  678. -** rights.  These rights are described in the Digia Qt LGPL Exception
  679. +** In addition, as a special exception, Nokia gives you certain additional
  680. +** rights.  These rights are described in the Nokia Qt LGPL Exception
  681.  ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  682.  **
  683.  ** GNU General Public License Usage
  684. @@ -34,7 +33,8 @@
  685.  ** ensure the GNU General Public License version 3.0 requirements will be
  686.  ** met: http://www.gnu.org/copyleft/gpl.html.
  687.  **
  688. -**
  689. +** If you have questions regarding the use of this file, please contact
  690. +** Nokia at qt-info@nokia.com.
  691.  ** $QT_END_LICENSE$
  692.  **
  693.  ****************************************************************************/
  694. @@ -43,7 +43,6 @@
  695.  #define QMUTEX_H
  696.  
  697.  #include <QtCore/qglobal.h>
  698. -#include <QtCore/qatomic.h>
  699.  #include <new>
  700.  
  701.  QT_BEGIN_HEADER
  702. @@ -54,8 +53,7 @@
  703.  
  704.  #ifndef QT_NO_THREAD
  705.  
  706. -class QAtomicInt;
  707. -class QMutexData;
  708. +class QMutexPrivate;
  709.  
  710.  class Q_CORE_EXPORT QMutex
  711.  {
  712. @@ -68,12 +66,12 @@
  713.      explicit QMutex(RecursionMode mode = NonRecursive);
  714.      ~QMutex();
  715.  
  716. -    void lock();     //### Qt5: make inline;
  717. -    inline void lockInline();
  718. -    bool tryLock();  //### Qt5: make inline;
  719. +    void lock();
  720. +    bool tryLock();
  721.      bool tryLock(int timeout);
  722. +    void unlock();
  723. +    inline void lockInline();
  724.      inline bool tryLockInline();
  725. -    void unlock();     //### Qt5: make inline;
  726.      inline void unlockInline();
  727.  
  728.  #if defined(QT3_SUPPORT)
  729. @@ -91,34 +89,35 @@
  730.  #endif
  731.  
  732.  private:
  733. -    void lockInternal();
  734. -    void unlockInternal();
  735.      Q_DISABLE_COPY(QMutex)
  736.  
  737. -    QMutexData *d;
  738. +    QMutexPrivate *d;
  739.  };
  740.  
  741. +inline void QMutex::unlockInline() { unlock(); }
  742. +inline bool QMutex::tryLockInline() { return tryLock(); }
  743. +inline void QMutex::lockInline() { lock(); }
  744. +
  745. +
  746.  class Q_CORE_EXPORT QMutexLocker
  747.  {
  748.  public:
  749.      inline explicit QMutexLocker(QMutex *m)
  750. +        : val(reinterpret_cast<quintptr>(m))
  751.      {
  752. -        Q_ASSERT_X((reinterpret_cast<quintptr>(m) & quintptr(1u)) == quintptr(0),
  753. +        Q_ASSERT_X((val & quintptr(1u)) == quintptr(0),
  754.                     "QMutexLocker", "QMutex pointer is misaligned");
  755. -        if (m) {
  756. -            m->lockInline();
  757. -            val = reinterpret_cast<quintptr>(m) | quintptr(1u);
  758. -        } else {
  759. -            val = 0;
  760. -        }
  761. +        relock();
  762.      }
  763.      inline ~QMutexLocker() { unlock(); }
  764.  
  765.      inline void unlock()
  766.      {
  767. +        if (val) {
  768.          if ((val & quintptr(1u)) == quintptr(1u)) {
  769.              val &= ~quintptr(1u);
  770. -            mutex()->unlockInline();
  771. +                mutex()->unlock();
  772. +            }
  773.          }
  774.      }
  775.  
  776. @@ -126,7 +125,7 @@
  777.      {
  778.          if (val) {
  779.              if ((val & quintptr(1u)) == quintptr(0u)) {
  780. -                mutex()->lockInline();
  781. +                mutex()->lock();
  782.                  val |= quintptr(1u);
  783.              }
  784.          }
  785. @@ -152,53 +151,6 @@
  786.      quintptr val;
  787.  };
  788.  
  789. -class QMutexData
  790. -{
  791. -    public:
  792. -        QAtomicInt contenders;
  793. -        const uint recursive : 1;
  794. -        uint reserved : 31;
  795. -    protected:
  796. -        QMutexData(QMutex::RecursionMode mode);
  797. -        ~QMutexData();
  798. -};
  799. -
  800. -#ifdef QT_NO_DEBUG
  801. -inline void QMutex::unlockInline()
  802. -{
  803. -    if (d->recursive) {
  804. -        unlock();
  805. -    } else if (!d->contenders.testAndSetRelease(1, 0)) {
  806. -        unlockInternal();
  807. -    }
  808. -}
  809. -
  810. -inline bool QMutex::tryLockInline()
  811. -{
  812. -    if (d->recursive) {
  813. -        return tryLock();
  814. -    } else {
  815. -        return d->contenders.testAndSetAcquire(0, 1);
  816. -    }
  817. -}
  818. -
  819. -inline void QMutex::lockInline()
  820. -{
  821. -    if (d->recursive) {
  822. -        lock();
  823. -    } else if(!tryLockInline()) {
  824. -        lockInternal();
  825. -    }
  826. -}
  827. -#else // QT_NO_DEBUG
  828. -//in debug we do not use inline calls in order to allow debugging tools
  829. -// to hook the mutex locking functions.
  830. -inline void QMutex::unlockInline() { unlock(); }
  831. -inline bool QMutex::tryLockInline() { return tryLock(); }
  832. -inline void QMutex::lockInline() { lock(); }
  833. -#endif // QT_NO_DEBUG
  834. -
  835. -
  836.  #else // QT_NO_THREAD
  837.  
  838.  
  839. @@ -211,16 +163,18 @@
  840.      inline ~QMutex() {}
  841.  
  842.      static inline void lock() {}
  843. -    static inline void lockInline() {}
  844. -    static inline bool tryLock(int timeout = 0) { Q_UNUSED(timeout); return true; }
  845. -    static inline bool tryLockInline() { return true; }
  846. -    static inline void unlock() {}
  847. -    static inline void unlockInline() {}
  848. +    static inline bool tryLock() { return true; }
  849. +    static inline bool tryLock(int timeout) { Q_UNUSED(timeout); return true; }
  850. +    static void unlock() {}
  851.  
  852.  #if defined(QT3_SUPPORT)
  853.      static inline QT3_SUPPORT bool locked() { return false; }
  854.  #endif
  855.  
  856. +    inline void lockInline();
  857. +    inline bool tryLockInline();
  858. +    inline void unlockInline();
  859. +
  860.  private:
  861.      Q_DISABLE_COPY(QMutex)
  862.  };
  863. @@ -239,6 +193,7 @@
  864.      Q_DISABLE_COPY(QMutexLocker)
  865.  };
  866.  
  867. +
  868.  #endif // QT_NO_THREAD
  869.  
  870.  QT_END_NAMESPACE
  871. 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
  872. --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qmutex_p.h  2012-11-23 14:09:55.000000000 +0400
  873. +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qmutex_p.h  2011-06-23 11:45:00.000000000 +0400
  874. @@ -1,18 +1,17 @@
  875.  /****************************************************************************
  876.  **
  877. -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
  878. -** Contact: http://www.qt-project.org/legal
  879. +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
  880. +** All rights reserved.
  881. +** Contact: Nokia Corporation (qt-info@nokia.com)
  882.  **
  883.  ** This file is part of the QtCore module of the Qt Toolkit.
  884.  **
  885.  ** $QT_BEGIN_LICENSE:LGPL$
  886. -** Commercial License Usage
  887. -** Licensees holding valid commercial Qt licenses may use this file in
  888. -** accordance with the commercial license agreement provided with the
  889. +** Commercial Usage
  890. +** Licensees holding valid Qt Commercial licenses may use this file in
  891. +** accordance with the Qt Commercial License Agreement provided with the
  892.  ** Software or, alternatively, in accordance with the terms contained in
  893. -** a written agreement between you and Digia.  For licensing terms and
  894. -** conditions see http://qt.digia.com/licensing.  For further information
  895. -** use the contact form at http://qt.digia.com/contact-us.
  896. +** a written agreement between you and Nokia.
  897.  **
  898.  ** GNU Lesser General Public License Usage
  899.  ** Alternatively, this file may be used under the terms of the GNU Lesser
  900. @@ -22,8 +21,8 @@
  901.  ** ensure the GNU Lesser General Public License version 2.1 requirements
  902.  ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  903.  **
  904. -** In addition, as a special exception, Digia gives you certain additional
  905. -** rights.  These rights are described in the Digia Qt LGPL Exception
  906. +** In addition, as a special exception, Nokia gives you certain additional
  907. +** rights.  These rights are described in the Nokia Qt LGPL Exception
  908.  ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  909.  **
  910.  ** GNU General Public License Usage
  911. @@ -34,7 +33,8 @@
  912.  ** ensure the GNU General Public License version 3.0 requirements will be
  913.  ** met: http://www.gnu.org/copyleft/gpl.html.
  914.  **
  915. -**
  916. +** If you have questions regarding the use of this file, please contact
  917. +** Nokia at qt-info@nokia.com.
  918.  ** $QT_END_LICENSE$
  919.  **
  920.  ****************************************************************************/
  921. @@ -56,46 +56,33 @@
  922.  
  923.  #include <QtCore/qglobal.h>
  924.  #include <QtCore/qnamespace.h>
  925. -#include <QtCore/qmutex.h>
  926. -
  927. -#if defined(Q_OS_SYMBIAN)
  928. -# include <e32std.h>
  929. -#endif
  930.  
  931.  QT_BEGIN_NAMESPACE
  932.  
  933. -class QMutexPrivate : public QMutexData {
  934. +class QMutexPrivate {
  935.  public:
  936.      QMutexPrivate(QMutex::RecursionMode mode);
  937.      ~QMutexPrivate();
  938.  
  939. +    ulong self();
  940.      bool wait(int timeout = -1);
  941.      void wakeUp();
  942.  
  943. -    // 1ms = 1000000ns
  944. -    enum { MaximumSpinTimeThreshold = 1000000 };
  945. -    volatile qint64 maximumSpinTime;
  946. -    volatile qint64 averageWaitTime;
  947. +    const bool recursive;
  948. +    QAtomicInt contenders;
  949. +    volatile int lastSpinCount;
  950.      Qt::HANDLE owner;
  951.      uint count;
  952.  
  953. -#if defined(Q_OS_UNIX) && !defined(Q_OS_LINUX) && !defined(Q_OS_SYMBIAN)
  954. +#if defined(Q_OS_UNIX)
  955.      volatile bool wakeup;
  956.      pthread_mutex_t mutex;
  957.      pthread_cond_t cond;
  958.  #elif defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
  959.      HANDLE event;
  960. -#elif defined(Q_OS_SYMBIAN)
  961. -    RSemaphore lock;
  962.  #endif
  963.  };
  964.  
  965. -inline QMutexData::QMutexData(QMutex::RecursionMode mode)
  966. -    : recursive(mode == QMutex::Recursive)
  967. -{}
  968. -
  969. -inline QMutexData::~QMutexData() {}
  970. -
  971.  QT_END_NAMESPACE
  972.  
  973.  #endif // QMUTEX_P_H
  974. 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
  975. --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qmutexpool.cpp  2012-11-23 14:09:55.000000000 +0400
  976. +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qmutexpool.cpp  2011-06-23 11:45:00.000000000 +0400
  977. @@ -1,18 +1,17 @@
  978.  /****************************************************************************
  979.  **
  980. -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
  981. -** Contact: http://www.qt-project.org/legal
  982. +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
  983. +** All rights reserved.
  984. +** Contact: Nokia Corporation (qt-info@nokia.com)
  985.  **
  986.  ** This file is part of the QtCore module of the Qt Toolkit.
  987.  **
  988.  ** $QT_BEGIN_LICENSE:LGPL$
  989. -** Commercial License Usage
  990. -** Licensees holding valid commercial Qt licenses may use this file in
  991. -** accordance with the commercial license agreement provided with the
  992. +** Commercial Usage
  993. +** Licensees holding valid Qt Commercial licenses may use this file in
  994. +** accordance with the Qt Commercial License Agreement provided with the
  995.  ** Software or, alternatively, in accordance with the terms contained in
  996. -** a written agreement between you and Digia.  For licensing terms and
  997. -** conditions see http://qt.digia.com/licensing.  For further information
  998. -** use the contact form at http://qt.digia.com/contact-us.
  999. +** a written agreement between you and Nokia.
  1000.  **
  1001.  ** GNU Lesser General Public License Usage
  1002.  ** Alternatively, this file may be used under the terms of the GNU Lesser
  1003. @@ -22,8 +21,8 @@
  1004.  ** ensure the GNU Lesser General Public License version 2.1 requirements
  1005.  ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  1006.  **
  1007. -** In addition, as a special exception, Digia gives you certain additional
  1008. -** rights.  These rights are described in the Digia Qt LGPL Exception
  1009. +** In addition, as a special exception, Nokia gives you certain additional
  1010. +** rights.  These rights are described in the Nokia Qt LGPL Exception
  1011.  ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  1012.  **
  1013.  ** GNU General Public License Usage
  1014. @@ -34,7 +33,8 @@
  1015.  ** ensure the GNU General Public License version 3.0 requirements will be
  1016.  ** met: http://www.gnu.org/copyleft/gpl.html.
  1017.  **
  1018. -**
  1019. +** If you have questions regarding the use of this file, please contact
  1020. +** Nokia at qt-info@nokia.com.
  1021.  ** $QT_END_LICENSE$
  1022.  **
  1023.  ****************************************************************************/
  1024. @@ -46,7 +46,7 @@
  1025.  
  1026.  QT_BEGIN_NAMESPACE
  1027.  
  1028. -// qt_global_mutexpool is here for backwards compatibility only,
  1029. +// qt_global_mutexpool is here for backwards compatability only,
  1030.  // use QMutexpool::instance() in new clode.
  1031.  Q_CORE_EXPORT QMutexPool *qt_global_mutexpool = 0;
  1032.  Q_GLOBAL_STATIC_WITH_ARGS(QMutexPool, globalMutexPool, (QMutex::Recursive))
  1033. @@ -124,20 +124,21 @@
  1034.  }
  1035.  
  1036.  /*!
  1037. -    \fn QMutexPool::get(const void *address)
  1038.      Returns a QMutex from the pool. QMutexPool uses the value \a address
  1039.      to determine which mutex is returned from the pool.
  1040.  */
  1041. -
  1042. -/*! \internal
  1043. -  create the mutex for the given index
  1044. - */
  1045. -QMutex *QMutexPool::createMutex(int index)
  1046. +QMutex *QMutexPool::get(const void *address)
  1047.  {
  1048. +    Q_ASSERT_X(address != 0, "QMutexPool::get()", "'address' argument cannot be zero");
  1049. +    int index = int((quintptr(address) >> (sizeof(address) >> 1)) % mutexes.count());
  1050. +
  1051. +    if (!mutexes[index]) {
  1052.      // mutex not created, create one
  1053.      QMutex *newMutex = new QMutex(recursionMode);
  1054.      if (!mutexes[index].testAndSetOrdered(0, newMutex))
  1055.          delete newMutex;
  1056. +    }
  1057. +
  1058.      return mutexes[index];
  1059.  }
  1060.  
  1061. 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
  1062. --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qmutexpool_p.h  2012-11-23 14:09:55.000000000 +0400
  1063. +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qmutexpool_p.h  2011-06-23 11:45:00.000000000 +0400
  1064. @@ -1,18 +1,17 @@
  1065.  /****************************************************************************
  1066.  **
  1067. -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
  1068. -** Contact: http://www.qt-project.org/legal
  1069. +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
  1070. +** All rights reserved.
  1071. +** Contact: Nokia Corporation (qt-info@nokia.com)
  1072.  **
  1073.  ** This file is part of the QtCore module of the Qt Toolkit.
  1074.  **
  1075.  ** $QT_BEGIN_LICENSE:LGPL$
  1076. -** Commercial License Usage
  1077. -** Licensees holding valid commercial Qt licenses may use this file in
  1078. -** accordance with the commercial license agreement provided with the
  1079. +** Commercial Usage
  1080. +** Licensees holding valid Qt Commercial licenses may use this file in
  1081. +** accordance with the Qt Commercial License Agreement provided with the
  1082.  ** Software or, alternatively, in accordance with the terms contained in
  1083. -** a written agreement between you and Digia.  For licensing terms and
  1084. -** conditions see http://qt.digia.com/licensing.  For further information
  1085. -** use the contact form at http://qt.digia.com/contact-us.
  1086. +** a written agreement between you and Nokia.
  1087.  **
  1088.  ** GNU Lesser General Public License Usage
  1089.  ** Alternatively, this file may be used under the terms of the GNU Lesser
  1090. @@ -22,8 +21,8 @@
  1091.  ** ensure the GNU Lesser General Public License version 2.1 requirements
  1092.  ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  1093.  **
  1094. -** In addition, as a special exception, Digia gives you certain additional
  1095. -** rights.  These rights are described in the Digia Qt LGPL Exception
  1096. +** In addition, as a special exception, Nokia gives you certain additional
  1097. +** rights.  These rights are described in the Nokia Qt LGPL Exception
  1098.  ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  1099.  **
  1100.  ** GNU General Public License Usage
  1101. @@ -34,7 +33,8 @@
  1102.  ** ensure the GNU General Public License version 3.0 requirements will be
  1103.  ** met: http://www.gnu.org/copyleft/gpl.html.
  1104.  **
  1105. -**
  1106. +** If you have questions regarding the use of this file, please contact
  1107. +** Nokia at qt-info@nokia.com.
  1108.  ** $QT_END_LICENSE$
  1109.  **
  1110.  ****************************************************************************/
  1111. @@ -67,19 +67,11 @@
  1112.      explicit QMutexPool(QMutex::RecursionMode recursionMode = QMutex::NonRecursive, int size = 131);
  1113.      ~QMutexPool();
  1114.  
  1115. -    inline QMutex *get(const void *address) {
  1116. -        int index = uint(quintptr(address)) % mutexes.count();
  1117. -        QMutex *m = mutexes[index];
  1118. -        if (m)
  1119. -            return m;
  1120. -        else
  1121. -            return createMutex(index);
  1122. -    }
  1123. +    QMutex *get(const void *address);
  1124.      static QMutexPool *instance();
  1125.      static QMutex *globalInstanceGet(const void *address);
  1126.  
  1127.  private:
  1128. -    QMutex *createMutex(int index);
  1129.      QVarLengthArray<QAtomicPointer<QMutex>, 131> mutexes;
  1130.      QMutex::RecursionMode recursionMode;
  1131.  };
  1132. 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
  1133. --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qmutex_symbian.cpp  2012-11-23 14:09:55.000000000 +0400
  1134. +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qmutex_symbian.cpp  1970-01-01 03:00:00.000000000 +0300
  1135. @@ -1,101 +0,0 @@
  1136. -/****************************************************************************
  1137. -**
  1138. -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
  1139. -** Contact: http://www.qt-project.org/legal
  1140. -**
  1141. -** This file is part of the QtCore module of the Qt Toolkit.
  1142. -**
  1143. -** $QT_BEGIN_LICENSE:LGPL$
  1144. -** Commercial License Usage
  1145. -** Licensees holding valid commercial Qt licenses may use this file in
  1146. -** accordance with the commercial license agreement provided with the
  1147. -** Software or, alternatively, in accordance with the terms contained in
  1148. -** a written agreement between you and Digia.  For licensing terms and
  1149. -** conditions see http://qt.digia.com/licensing.  For further information
  1150. -** use the contact form at http://qt.digia.com/contact-us.
  1151. -**
  1152. -** GNU Lesser General Public License Usage
  1153. -** Alternatively, this file may be used under the terms of the GNU Lesser
  1154. -** General Public License version 2.1 as published by the Free Software
  1155. -** Foundation and appearing in the file LICENSE.LGPL included in the
  1156. -** packaging of this file.  Please review the following information to
  1157. -** ensure the GNU Lesser General Public License version 2.1 requirements
  1158. -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  1159. -**
  1160. -** In addition, as a special exception, Digia gives you certain additional
  1161. -** rights.  These rights are described in the Digia Qt LGPL Exception
  1162. -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  1163. -**
  1164. -** GNU General Public License Usage
  1165. -** Alternatively, this file may be used under the terms of the GNU
  1166. -** General Public License version 3.0 as published by the Free Software
  1167. -** Foundation and appearing in the file LICENSE.GPL included in the
  1168. -** packaging of this file.  Please review the following information to
  1169. -** ensure the GNU General Public License version 3.0 requirements will be
  1170. -** met: http://www.gnu.org/copyleft/gpl.html.
  1171. -**
  1172. -**
  1173. -** $QT_END_LICENSE$
  1174. -**
  1175. -****************************************************************************/
  1176. -
  1177. -#include "qplatformdefs.h"
  1178. -#include "qmutex.h"
  1179. -
  1180. -#ifndef QT_NO_THREAD
  1181. -#include "qatomic.h"
  1182. -#include "qelapsedtimer.h"
  1183. -#include "qthread.h"
  1184. -#include "qmutex_p.h"
  1185. -
  1186. -QT_BEGIN_NAMESPACE
  1187. -
  1188. -
  1189. -QMutexPrivate::QMutexPrivate(QMutex::RecursionMode mode)
  1190. -    : QMutexData(mode), maximumSpinTime(MaximumSpinTimeThreshold), averageWaitTime(0), owner(0), count(0)
  1191. -{
  1192. -    int r = lock.CreateLocal(0);
  1193. -    if (r != KErrNone)
  1194. -        qWarning("QMutex: failed to create lock, error %d", r);
  1195. -    qt_symbian_throwIfError(r);
  1196. -}
  1197. -
  1198. -QMutexPrivate::~QMutexPrivate()
  1199. -{
  1200. -    lock.Close();
  1201. -}
  1202. -
  1203. -bool QMutexPrivate::wait(int timeout)
  1204. -{
  1205. -    if (contenders.fetchAndAddAcquire(1) == 0) {
  1206. -        // lock acquired without waiting
  1207. -        return true;
  1208. -    }
  1209. -    int r = KErrTimedOut;
  1210. -    if (timeout < 0) {
  1211. -        lock.Wait();
  1212. -        r = KErrNone;
  1213. -    } else {
  1214. -        // Symbian lock waits are specified in microseconds.
  1215. -        // The wait is therefore chunked.
  1216. -        // KErrNone indicates success, KErrGeneral and KErrArgument are real fails, anything else is a timeout
  1217. -        do {
  1218. -            int waitTime = qMin(KMaxTInt / 1000, timeout);
  1219. -            timeout -= waitTime;
  1220. -            // Symbian undocumented feature - 0us means no timeout! Use a minimum of 1
  1221. -            r = lock.Wait(qMax(1, waitTime * 1000));
  1222. -        } while (r != KErrNone && r != KErrGeneral && r != KErrArgument && timeout > 0);
  1223. -    }
  1224. -    bool returnValue = (r == KErrNone);
  1225. -    contenders.deref();
  1226. -    return returnValue;
  1227. -}
  1228. -
  1229. -void QMutexPrivate::wakeUp()
  1230. -{
  1231. -    lock.Signal();
  1232. -}
  1233. -
  1234. -QT_END_NAMESPACE
  1235. -
  1236. -#endif // QT_NO_THREAD
  1237. 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
  1238. --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qmutex_unix.cpp 2012-11-23 14:09:55.000000000 +0400
  1239. +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qmutex_unix.cpp 2011-06-23 11:45:00.000000000 +0400
  1240. @@ -1,18 +1,17 @@
  1241.  /****************************************************************************
  1242.  **
  1243. -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
  1244. -** Contact: http://www.qt-project.org/legal
  1245. +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
  1246. +** All rights reserved.
  1247. +** Contact: Nokia Corporation (qt-info@nokia.com)
  1248.  **
  1249.  ** This file is part of the QtCore module of the Qt Toolkit.
  1250.  **
  1251.  ** $QT_BEGIN_LICENSE:LGPL$
  1252. -** Commercial License Usage
  1253. -** Licensees holding valid commercial Qt licenses may use this file in
  1254. -** accordance with the commercial license agreement provided with the
  1255. +** Commercial Usage
  1256. +** Licensees holding valid Qt Commercial licenses may use this file in
  1257. +** accordance with the Qt Commercial License Agreement provided with the
  1258.  ** Software or, alternatively, in accordance with the terms contained in
  1259. -** a written agreement between you and Digia.  For licensing terms and
  1260. -** conditions see http://qt.digia.com/licensing.  For further information
  1261. -** use the contact form at http://qt.digia.com/contact-us.
  1262. +** a written agreement between you and Nokia.
  1263.  **
  1264.  ** GNU Lesser General Public License Usage
  1265.  ** Alternatively, this file may be used under the terms of the GNU Lesser
  1266. @@ -22,8 +21,8 @@
  1267.  ** ensure the GNU Lesser General Public License version 2.1 requirements
  1268.  ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  1269.  **
  1270. -** In addition, as a special exception, Digia gives you certain additional
  1271. -** rights.  These rights are described in the Digia Qt LGPL Exception
  1272. +** In addition, as a special exception, Nokia gives you certain additional
  1273. +** rights.  These rights are described in the Nokia Qt LGPL Exception
  1274.  ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  1275.  **
  1276.  ** GNU General Public License Usage
  1277. @@ -34,7 +33,8 @@
  1278.  ** ensure the GNU General Public License version 3.0 requirements will be
  1279.  ** met: http://www.gnu.org/copyleft/gpl.html.
  1280.  **
  1281. -**
  1282. +** If you have questions regarding the use of this file, please contact
  1283. +** Nokia at qt-info@nokia.com.
  1284.  ** $QT_END_LICENSE$
  1285.  **
  1286.  ****************************************************************************/
  1287. @@ -53,97 +53,30 @@
  1288.  #undef wakeup
  1289.  #endif
  1290.  
  1291. -#if defined(Q_OS_MAC)
  1292. -# include <mach/mach.h>
  1293. -# include <mach/task.h>
  1294. -#elif defined(Q_OS_LINUX)
  1295. -# include <linux/futex.h>
  1296. -# include <sys/syscall.h>
  1297. -# include <unistd.h>
  1298. -# include <QtCore/qelapsedtimer.h>
  1299. -#endif
  1300. -
  1301.  QT_BEGIN_NAMESPACE
  1302.  
  1303. -#if !defined(Q_OS_LINUX)
  1304.  static void report_error(int code, const char *where, const char *what)
  1305.  {
  1306.      if (code != 0)
  1307.          qWarning("%s: %s failure: %s", where, what, qPrintable(qt_error_string(code)));
  1308.  }
  1309. -#endif
  1310.  
  1311.  
  1312.  QMutexPrivate::QMutexPrivate(QMutex::RecursionMode mode)
  1313. -    : QMutexData(mode), maximumSpinTime(MaximumSpinTimeThreshold), averageWaitTime(0), owner(0), count(0)
  1314. +    : recursive(mode == QMutex::Recursive), contenders(0), lastSpinCount(0), owner(0), count(0), wakeup(false)
  1315.  {
  1316. -#if !defined(Q_OS_LINUX)
  1317. -    wakeup = false;
  1318.      report_error(pthread_mutex_init(&mutex, NULL), "QMutex", "mutex init");
  1319.      report_error(pthread_cond_init(&cond, NULL), "QMutex", "cv init");
  1320. -#endif
  1321.  }
  1322.  
  1323.  QMutexPrivate::~QMutexPrivate()
  1324.  {
  1325. -#if !defined(Q_OS_LINUX)
  1326.      report_error(pthread_cond_destroy(&cond), "QMutex", "cv destroy");
  1327.      report_error(pthread_mutex_destroy(&mutex), "QMutex", "mutex destroy");
  1328. -#endif
  1329. -}
  1330. -
  1331. -#if defined(Q_OS_LINUX)
  1332. -
  1333. -static inline int _q_futex(volatile int *addr, int op, int val, const struct timespec *timeout, int *addr2, int val2)
  1334. -{
  1335. -    return syscall(SYS_futex, addr, op, val, timeout, addr2, val2);
  1336.  }
  1337.  
  1338.  bool QMutexPrivate::wait(int timeout)
  1339.  {
  1340. -    struct timespec ts, *pts = 0;
  1341. -    QElapsedTimer timer;
  1342. -    if (timeout >= 0) {
  1343. -        ts.tv_nsec = ((timeout % 1000) * 1000) * 1000;
  1344. -        ts.tv_sec = (timeout / 1000);
  1345. -        pts = &ts;
  1346. -        timer.start();
  1347. -    }
  1348. -    while (contenders.fetchAndStoreAcquire(2) > 0) {
  1349. -        int r = _q_futex(&contenders._q_value, FUTEX_WAIT, 2, pts, 0, 0);
  1350. -        if (r != 0 && errno == ETIMEDOUT)
  1351. -            return false;
  1352. -
  1353. -        if (pts) {
  1354. -            // recalculate the timeout
  1355. -            qint64 xtimeout = timeout * 1000 * 1000;
  1356. -            xtimeout -= timer.nsecsElapsed();
  1357. -            if (xtimeout < 0) {
  1358. -                // timer expired after we returned
  1359. -                return false;
  1360. -            }
  1361. -
  1362. -            ts.tv_sec = xtimeout / Q_INT64_C(1000) / 1000 / 1000;
  1363. -            ts.tv_nsec = xtimeout % (Q_INT64_C(1000) * 1000 * 1000);
  1364. -        }
  1365. -    }
  1366. -    return true;
  1367. -}
  1368. -
  1369. -void QMutexPrivate::wakeUp()
  1370. -{
  1371. -    (void) contenders.fetchAndStoreRelease(0);
  1372. -    (void) _q_futex(&contenders._q_value, FUTEX_WAKE, 1, 0, 0, 0);
  1373. -}
  1374. -
  1375. -#else // !Q_OS_LINUX
  1376. -
  1377. -bool QMutexPrivate::wait(int timeout)
  1378. -{
  1379. -    if (contenders.fetchAndAddAcquire(1) == 0) {
  1380. -        // lock acquired without waiting
  1381. -        return true;
  1382. -    }
  1383.      report_error(pthread_mutex_lock(&mutex), "QMutex::lock", "mutex lock");
  1384.      int errorCode = 0;
  1385.      while (!wakeup) {
  1386. @@ -171,7 +104,6 @@
  1387.      }
  1388.      wakeup = false;
  1389.      report_error(pthread_mutex_unlock(&mutex), "QMutex::lock", "mutex unlock");
  1390. -    contenders.deref();
  1391.      return errorCode == 0;
  1392.  }
  1393.  
  1394. @@ -183,8 +115,6 @@
  1395.      report_error(pthread_mutex_unlock(&mutex), "QMutex::unlock", "mutex unlock");
  1396.  }
  1397.  
  1398. -#endif // !Q_OS_LINUX
  1399. -
  1400.  QT_END_NAMESPACE
  1401.  
  1402.  #endif // QT_NO_THREAD
  1403. 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
  1404. --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qmutex_win.cpp  2012-11-23 14:09:55.000000000 +0400
  1405. +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qmutex_win.cpp  2011-06-23 11:45:00.000000000 +0400
  1406. @@ -1,18 +1,17 @@
  1407.  /****************************************************************************
  1408.  **
  1409. -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
  1410. -** Contact: http://www.qt-project.org/legal
  1411. +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
  1412. +** All rights reserved.
  1413. +** Contact: Nokia Corporation (qt-info@nokia.com)
  1414.  **
  1415.  ** This file is part of the QtCore module of the Qt Toolkit.
  1416.  **
  1417.  ** $QT_BEGIN_LICENSE:LGPL$
  1418. -** Commercial License Usage
  1419. -** Licensees holding valid commercial Qt licenses may use this file in
  1420. -** accordance with the commercial license agreement provided with the
  1421. +** Commercial Usage
  1422. +** Licensees holding valid Qt Commercial licenses may use this file in
  1423. +** accordance with the Qt Commercial License Agreement provided with the
  1424.  ** Software or, alternatively, in accordance with the terms contained in
  1425. -** a written agreement between you and Digia.  For licensing terms and
  1426. -** conditions see http://qt.digia.com/licensing.  For further information
  1427. -** use the contact form at http://qt.digia.com/contact-us.
  1428. +** a written agreement between you and Nokia.
  1429.  **
  1430.  ** GNU Lesser General Public License Usage
  1431.  ** Alternatively, this file may be used under the terms of the GNU Lesser
  1432. @@ -22,8 +21,8 @@
  1433.  ** ensure the GNU Lesser General Public License version 2.1 requirements
  1434.  ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  1435.  **
  1436. -** In addition, as a special exception, Digia gives you certain additional
  1437. -** rights.  These rights are described in the Digia Qt LGPL Exception
  1438. +** In addition, as a special exception, Nokia gives you certain additional
  1439. +** rights.  These rights are described in the Nokia Qt LGPL Exception
  1440.  ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  1441.  **
  1442.  ** GNU General Public License Usage
  1443. @@ -34,7 +33,8 @@
  1444.  ** ensure the GNU General Public License version 3.0 requirements will be
  1445.  ** met: http://www.gnu.org/copyleft/gpl.html.
  1446.  **
  1447. -**
  1448. +** If you have questions regarding the use of this file, please contact
  1449. +** Nokia at qt-info@nokia.com.
  1450.  ** $QT_END_LICENSE$
  1451.  **
  1452.  ****************************************************************************/
  1453. @@ -48,7 +48,7 @@
  1454.  QT_BEGIN_NAMESPACE
  1455.  
  1456.  QMutexPrivate::QMutexPrivate(QMutex::RecursionMode mode)
  1457. -    : QMutexData(mode), maximumSpinTime(MaximumSpinTimeThreshold), averageWaitTime(0), owner(0), count(0)
  1458. +    : recursive(mode == QMutex::Recursive), contenders(0), lastSpinCount(0), owner(0), count(0)
  1459.  {
  1460.      event = CreateEvent(0, FALSE, FALSE, 0);
  1461.      if (!event)
  1462. @@ -60,13 +60,7 @@
  1463.  
  1464.  bool QMutexPrivate::wait(int timeout)
  1465.  {
  1466. -    if (contenders.fetchAndAddAcquire(1) == 0) {
  1467. -        // lock acquired without waiting
  1468. -        return true;
  1469. -    }
  1470. -    bool returnValue = (WaitForSingleObject(event, timeout < 0 ? INFINITE : timeout) ==  WAIT_OBJECT_0);
  1471. -    contenders.deref();
  1472. -    return returnValue;
  1473. +    return WaitForSingleObject(event, timeout < 0 ? INFINITE : timeout) ==  WAIT_OBJECT_0;
  1474.  }
  1475.  
  1476.  void QMutexPrivate::wakeUp()
  1477. 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
  1478. --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qorderedmutexlocker_p.h 2012-11-23 14:09:55.000000000 +0400
  1479. +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qorderedmutexlocker_p.h 2011-06-23 11:45:00.000000000 +0400
  1480. @@ -1,18 +1,17 @@
  1481.  /****************************************************************************
  1482.  **
  1483. -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
  1484. -** Contact: http://www.qt-project.org/legal
  1485. +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
  1486. +** All rights reserved.
  1487. +** Contact: Nokia Corporation (qt-info@nokia.com)
  1488.  **
  1489.  ** This file is part of the QtCore module of the Qt Toolkit.
  1490.  **
  1491.  ** $QT_BEGIN_LICENSE:LGPL$
  1492. -** Commercial License Usage
  1493. -** Licensees holding valid commercial Qt licenses may use this file in
  1494. -** accordance with the commercial license agreement provided with the
  1495. +** Commercial Usage
  1496. +** Licensees holding valid Qt Commercial licenses may use this file in
  1497. +** accordance with the Qt Commercial License Agreement provided with the
  1498.  ** Software or, alternatively, in accordance with the terms contained in
  1499. -** a written agreement between you and Digia.  For licensing terms and
  1500. -** conditions see http://qt.digia.com/licensing.  For further information
  1501. -** use the contact form at http://qt.digia.com/contact-us.
  1502. +** a written agreement between you and Nokia.
  1503.  **
  1504.  ** GNU Lesser General Public License Usage
  1505.  ** Alternatively, this file may be used under the terms of the GNU Lesser
  1506. @@ -22,8 +21,8 @@
  1507.  ** ensure the GNU Lesser General Public License version 2.1 requirements
  1508.  ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  1509.  **
  1510. -** In addition, as a special exception, Digia gives you certain additional
  1511. -** rights.  These rights are described in the Digia Qt LGPL Exception
  1512. +** In addition, as a special exception, Nokia gives you certain additional
  1513. +** rights.  These rights are described in the Nokia Qt LGPL Exception
  1514.  ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  1515.  **
  1516.  ** GNU General Public License Usage
  1517. @@ -34,7 +33,8 @@
  1518.  ** ensure the GNU General Public License version 3.0 requirements will be
  1519.  ** met: http://www.gnu.org/copyleft/gpl.html.
  1520.  **
  1521. -**
  1522. +** If you have questions regarding the use of this file, please contact
  1523. +** Nokia at qt-info@nokia.com.
  1524.  ** $QT_END_LICENSE$
  1525.  **
  1526.  ****************************************************************************/
  1527. @@ -55,7 +55,7 @@
  1528.  
  1529.  QT_BEGIN_NAMESPACE
  1530.  
  1531. -#include <QtCore/qmutex.h>
  1532. +class QMutex;
  1533.  
  1534.  /*
  1535.    Locks 2 mutexes in a defined order, avoiding a recursive lock if
  1536. @@ -79,8 +79,8 @@
  1537.      void relock()
  1538.      {
  1539.          if (!locked) {
  1540. -            if (mtx1) mtx1->lockInline();
  1541. -            if (mtx2) mtx2->lockInline();
  1542. +            if (mtx1) mtx1->lock();
  1543. +            if (mtx2) mtx2->lock();
  1544.              locked = true;
  1545.          }
  1546.      }
  1547. @@ -88,8 +88,8 @@
  1548.      void unlock()
  1549.      {
  1550.          if (locked) {
  1551. -            if (mtx1) mtx1->unlockInline();
  1552. -            if (mtx2) mtx2->unlockInline();
  1553. +            if (mtx1) mtx1->unlock();
  1554. +            if (mtx2) mtx2->unlock();
  1555.              locked = false;
  1556.          }
  1557.      }
  1558. @@ -100,14 +100,12 @@
  1559.          if (mtx1 == mtx2)
  1560.              return false;
  1561.          if (mtx1 < mtx2) {
  1562. -            mtx2->lockInline();
  1563. +            mtx2->lock();
  1564.              return true;
  1565.          }
  1566. -        if (!mtx2->tryLockInline()) {
  1567.              mtx1->unlock();
  1568.              mtx2->lock();
  1569.              mtx1->lock();
  1570. -        }
  1571.          return true;
  1572.      }
  1573.  
  1574. 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
  1575. --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qreadwritelock.cpp  2012-11-23 14:09:55.000000000 +0400
  1576. +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qreadwritelock.cpp  2011-06-23 11:45:00.000000000 +0400
  1577. @@ -1,18 +1,17 @@
  1578.  /****************************************************************************
  1579.  **
  1580. -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
  1581. -** Contact: http://www.qt-project.org/legal
  1582. +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
  1583. +** All rights reserved.
  1584. +** Contact: Nokia Corporation (qt-info@nokia.com)
  1585.  **
  1586.  ** This file is part of the QtCore module of the Qt Toolkit.
  1587.  **
  1588.  ** $QT_BEGIN_LICENSE:LGPL$
  1589. -** Commercial License Usage
  1590. -** Licensees holding valid commercial Qt licenses may use this file in
  1591. -** accordance with the commercial license agreement provided with the
  1592. +** Commercial Usage
  1593. +** Licensees holding valid Qt Commercial licenses may use this file in
  1594. +** accordance with the Qt Commercial License Agreement provided with the
  1595.  ** Software or, alternatively, in accordance with the terms contained in
  1596. -** a written agreement between you and Digia.  For licensing terms and
  1597. -** conditions see http://qt.digia.com/licensing.  For further information
  1598. -** use the contact form at http://qt.digia.com/contact-us.
  1599. +** a written agreement between you and Nokia.
  1600.  **
  1601.  ** GNU Lesser General Public License Usage
  1602.  ** Alternatively, this file may be used under the terms of the GNU Lesser
  1603. @@ -22,8 +21,8 @@
  1604.  ** ensure the GNU Lesser General Public License version 2.1 requirements
  1605.  ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  1606.  **
  1607. -** In addition, as a special exception, Digia gives you certain additional
  1608. -** rights.  These rights are described in the Digia Qt LGPL Exception
  1609. +** In addition, as a special exception, Nokia gives you certain additional
  1610. +** rights.  These rights are described in the Nokia Qt LGPL Exception
  1611.  ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  1612.  **
  1613.  ** GNU General Public License Usage
  1614. @@ -34,7 +33,8 @@
  1615.  ** ensure the GNU General Public License version 3.0 requirements will be
  1616.  ** met: http://www.gnu.org/copyleft/gpl.html.
  1617.  **
  1618. -**
  1619. +** If you have questions regarding the use of this file, please contact
  1620. +** Nokia at qt-info@nokia.com.
  1621.  ** $QT_END_LICENSE$
  1622.  **
  1623.  ****************************************************************************/
  1624. @@ -252,7 +252,7 @@
  1625.  
  1626.      while (d->accessCount < 0 || d->waitingWriters) {
  1627.          ++d->waitingReaders;
  1628. -        bool success = d->readerWait.wait(&d->mutex, timeout < 0 ? ULONG_MAX : ulong(timeout));
  1629. +        bool success = d->readerWait.wait(&d->mutex, timeout < 0 ? ULONG_MAX : timeout);
  1630.          --d->waitingReaders;
  1631.          if (!success)
  1632.              return false;
  1633. @@ -374,7 +374,7 @@
  1634.  
  1635.      while (d->accessCount != 0) {
  1636.          ++d->waitingWriters;
  1637. -        bool success = d->writerWait.wait(&d->mutex, timeout < 0 ? ULONG_MAX : ulong(timeout));
  1638. +        bool success = d->writerWait.wait(&d->mutex, timeout < 0 ? ULONG_MAX : timeout);
  1639.          --d->waitingWriters;
  1640.  
  1641.          if (!success)
  1642. 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
  1643. --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qreadwritelock.h    2012-11-23 14:09:55.000000000 +0400
  1644. +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qreadwritelock.h    2011-06-23 11:45:00.000000000 +0400
  1645. @@ -1,18 +1,17 @@
  1646.  /****************************************************************************
  1647.  **
  1648. -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
  1649. -** Contact: http://www.qt-project.org/legal
  1650. +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
  1651. +** All rights reserved.
  1652. +** Contact: Nokia Corporation (qt-info@nokia.com)
  1653.  **
  1654.  ** This file is part of the QtCore module of the Qt Toolkit.
  1655.  **
  1656.  ** $QT_BEGIN_LICENSE:LGPL$
  1657. -** Commercial License Usage
  1658. -** Licensees holding valid commercial Qt licenses may use this file in
  1659. -** accordance with the commercial license agreement provided with the
  1660. +** Commercial Usage
  1661. +** Licensees holding valid Qt Commercial licenses may use this file in
  1662. +** accordance with the Qt Commercial License Agreement provided with the
  1663.  ** Software or, alternatively, in accordance with the terms contained in
  1664. -** a written agreement between you and Digia.  For licensing terms and
  1665. -** conditions see http://qt.digia.com/licensing.  For further information
  1666. -** use the contact form at http://qt.digia.com/contact-us.
  1667. +** a written agreement between you and Nokia.
  1668.  **
  1669.  ** GNU Lesser General Public License Usage
  1670.  ** Alternatively, this file may be used under the terms of the GNU Lesser
  1671. @@ -22,8 +21,8 @@
  1672.  ** ensure the GNU Lesser General Public License version 2.1 requirements
  1673.  ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  1674.  **
  1675. -** In addition, as a special exception, Digia gives you certain additional
  1676. -** rights.  These rights are described in the Digia Qt LGPL Exception
  1677. +** In addition, as a special exception, Nokia gives you certain additional
  1678. +** rights.  These rights are described in the Nokia Qt LGPL Exception
  1679.  ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  1680.  **
  1681.  ** GNU General Public License Usage
  1682. @@ -34,7 +33,8 @@
  1683.  ** ensure the GNU General Public License version 3.0 requirements will be
  1684.  ** met: http://www.gnu.org/copyleft/gpl.html.
  1685.  **
  1686. -**
  1687. +** If you have questions regarding the use of this file, please contact
  1688. +** Nokia at qt-info@nokia.com.
  1689.  ** $QT_END_LICENSE$
  1690.  **
  1691.  ****************************************************************************/
  1692. 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
  1693. --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qreadwritelock_p.h  2012-11-23 14:09:55.000000000 +0400
  1694. +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qreadwritelock_p.h  2011-06-23 11:45:00.000000000 +0400
  1695. @@ -1,18 +1,17 @@
  1696.  /****************************************************************************
  1697.  **
  1698. -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
  1699. -** Contact: http://www.qt-project.org/legal
  1700. +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
  1701. +** All rights reserved.
  1702. +** Contact: Nokia Corporation (qt-info@nokia.com)
  1703.  **
  1704.  ** This file is part of the QtCore module of the Qt Toolkit.
  1705.  **
  1706.  ** $QT_BEGIN_LICENSE:LGPL$
  1707. -** Commercial License Usage
  1708. -** Licensees holding valid commercial Qt licenses may use this file in
  1709. -** accordance with the commercial license agreement provided with the
  1710. +** Commercial Usage
  1711. +** Licensees holding valid Qt Commercial licenses may use this file in
  1712. +** accordance with the Qt Commercial License Agreement provided with the
  1713.  ** Software or, alternatively, in accordance with the terms contained in
  1714. -** a written agreement between you and Digia.  For licensing terms and
  1715. -** conditions see http://qt.digia.com/licensing.  For further information
  1716. -** use the contact form at http://qt.digia.com/contact-us.
  1717. +** a written agreement between you and Nokia.
  1718.  **
  1719.  ** GNU Lesser General Public License Usage
  1720.  ** Alternatively, this file may be used under the terms of the GNU Lesser
  1721. @@ -22,8 +21,8 @@
  1722.  ** ensure the GNU Lesser General Public License version 2.1 requirements
  1723.  ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  1724.  **
  1725. -** In addition, as a special exception, Digia gives you certain additional
  1726. -** rights.  These rights are described in the Digia Qt LGPL Exception
  1727. +** In addition, as a special exception, Nokia gives you certain additional
  1728. +** rights.  These rights are described in the Nokia Qt LGPL Exception
  1729.  ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  1730.  **
  1731.  ** GNU General Public License Usage
  1732. @@ -34,7 +33,8 @@
  1733.  ** ensure the GNU General Public License version 3.0 requirements will be
  1734.  ** met: http://www.gnu.org/copyleft/gpl.html.
  1735.  **
  1736. -**
  1737. +** If you have questions regarding the use of this file, please contact
  1738. +** Nokia at qt-info@nokia.com.
  1739.  ** $QT_END_LICENSE$
  1740.  **
  1741.  ****************************************************************************/
  1742. 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
  1743. --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qsemaphore.cpp  2012-11-23 14:09:55.000000000 +0400
  1744. +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qsemaphore.cpp  2011-06-23 11:45:00.000000000 +0400
  1745. @@ -1,18 +1,17 @@
  1746.  /****************************************************************************
  1747.  **
  1748. -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
  1749. -** Contact: http://www.qt-project.org/legal
  1750. +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
  1751. +** All rights reserved.
  1752. +** Contact: Nokia Corporation (qt-info@nokia.com)
  1753.  **
  1754.  ** This file is part of the QtCore module of the Qt Toolkit.
  1755.  **
  1756.  ** $QT_BEGIN_LICENSE:LGPL$
  1757. -** Commercial License Usage
  1758. -** Licensees holding valid commercial Qt licenses may use this file in
  1759. -** accordance with the commercial license agreement provided with the
  1760. +** Commercial Usage
  1761. +** Licensees holding valid Qt Commercial licenses may use this file in
  1762. +** accordance with the Qt Commercial License Agreement provided with the
  1763.  ** Software or, alternatively, in accordance with the terms contained in
  1764. -** a written agreement between you and Digia.  For licensing terms and
  1765. -** conditions see http://qt.digia.com/licensing.  For further information
  1766. -** use the contact form at http://qt.digia.com/contact-us.
  1767. +** a written agreement between you and Nokia.
  1768.  **
  1769.  ** GNU Lesser General Public License Usage
  1770.  ** Alternatively, this file may be used under the terms of the GNU Lesser
  1771. @@ -22,8 +21,8 @@
  1772.  ** ensure the GNU Lesser General Public License version 2.1 requirements
  1773.  ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  1774.  **
  1775. -** In addition, as a special exception, Digia gives you certain additional
  1776. -** rights.  These rights are described in the Digia Qt LGPL Exception
  1777. +** In addition, as a special exception, Nokia gives you certain additional
  1778. +** rights.  These rights are described in the Nokia Qt LGPL Exception
  1779.  ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  1780.  **
  1781.  ** GNU General Public License Usage
  1782. @@ -34,7 +33,8 @@
  1783.  ** ensure the GNU General Public License version 3.0 requirements will be
  1784.  ** met: http://www.gnu.org/copyleft/gpl.html.
  1785.  **
  1786. -**
  1787. +** If you have questions regarding the use of this file, please contact
  1788. +** Nokia at qt-info@nokia.com.
  1789.  ** $QT_END_LICENSE$
  1790.  **
  1791.  ****************************************************************************/
  1792. @@ -44,8 +44,6 @@
  1793.  #ifndef QT_NO_THREAD
  1794.  #include "qmutex.h"
  1795.  #include "qwaitcondition.h"
  1796. -#include "qelapsedtimer.h"
  1797. -#include "qdatetime.h"
  1798.  
  1799.  QT_BEGIN_NAMESPACE
  1800.  
  1801. @@ -220,12 +218,8 @@
  1802.          while (n > d->avail)
  1803.              d->cond.wait(locker.mutex());
  1804.      } else {
  1805. -        QElapsedTimer timer;
  1806. -        timer.start();
  1807.          while (n > d->avail) {
  1808. -            const qint64 elapsed = timer.elapsed();
  1809. -            if (timeout - elapsed <= 0
  1810. -                || !d->cond.wait(locker.mutex(), timeout - elapsed))
  1811. +            if (!d->cond.wait(locker.mutex(), timeout))
  1812.                  return false;
  1813.          }
  1814.      }
  1815. 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
  1816. --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qsemaphore.h    2012-11-23 14:09:55.000000000 +0400
  1817. +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qsemaphore.h    2011-06-23 11:45:00.000000000 +0400
  1818. @@ -1,18 +1,17 @@
  1819.  /****************************************************************************
  1820.  **
  1821. -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
  1822. -** Contact: http://www.qt-project.org/legal
  1823. +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
  1824. +** All rights reserved.
  1825. +** Contact: Nokia Corporation (qt-info@nokia.com)
  1826.  **
  1827.  ** This file is part of the QtCore module of the Qt Toolkit.
  1828.  **
  1829.  ** $QT_BEGIN_LICENSE:LGPL$
  1830. -** Commercial License Usage
  1831. -** Licensees holding valid commercial Qt licenses may use this file in
  1832. -** accordance with the commercial license agreement provided with the
  1833. +** Commercial Usage
  1834. +** Licensees holding valid Qt Commercial licenses may use this file in
  1835. +** accordance with the Qt Commercial License Agreement provided with the
  1836.  ** Software or, alternatively, in accordance with the terms contained in
  1837. -** a written agreement between you and Digia.  For licensing terms and
  1838. -** conditions see http://qt.digia.com/licensing.  For further information
  1839. -** use the contact form at http://qt.digia.com/contact-us.
  1840. +** a written agreement between you and Nokia.
  1841.  **
  1842.  ** GNU Lesser General Public License Usage
  1843.  ** Alternatively, this file may be used under the terms of the GNU Lesser
  1844. @@ -22,8 +21,8 @@
  1845.  ** ensure the GNU Lesser General Public License version 2.1 requirements
  1846.  ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  1847.  **
  1848. -** In addition, as a special exception, Digia gives you certain additional
  1849. -** rights.  These rights are described in the Digia Qt LGPL Exception
  1850. +** In addition, as a special exception, Nokia gives you certain additional
  1851. +** rights.  These rights are described in the Nokia Qt LGPL Exception
  1852.  ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  1853.  **
  1854.  ** GNU General Public License Usage
  1855. @@ -34,7 +33,8 @@
  1856.  ** ensure the GNU General Public License version 3.0 requirements will be
  1857.  ** met: http://www.gnu.org/copyleft/gpl.html.
  1858.  **
  1859. -**
  1860. +** If you have questions regarding the use of this file, please contact
  1861. +** Nokia at qt-info@nokia.com.
  1862.  ** $QT_END_LICENSE$
  1863.  **
  1864.  ****************************************************************************/
  1865. 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
  1866. --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qthread.cpp 2012-11-23 14:09:55.000000000 +0400
  1867. +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qthread.cpp 2013-02-14 21:08:00.000000000 +0400
  1868. @@ -1,18 +1,17 @@
  1869.  /****************************************************************************
  1870.  **
  1871. -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
  1872. -** Contact: http://www.qt-project.org/legal
  1873. +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
  1874. +** All rights reserved.
  1875. +** Contact: Nokia Corporation (qt-info@nokia.com)
  1876.  **
  1877.  ** This file is part of the QtCore module of the Qt Toolkit.
  1878.  **
  1879.  ** $QT_BEGIN_LICENSE:LGPL$
  1880. -** Commercial License Usage
  1881. -** Licensees holding valid commercial Qt licenses may use this file in
  1882. -** accordance with the commercial license agreement provided with the
  1883. +** Commercial Usage
  1884. +** Licensees holding valid Qt Commercial licenses may use this file in
  1885. +** accordance with the Qt Commercial License Agreement provided with the
  1886.  ** Software or, alternatively, in accordance with the terms contained in
  1887. -** a written agreement between you and Digia.  For licensing terms and
  1888. -** conditions see http://qt.digia.com/licensing.  For further information
  1889. -** use the contact form at http://qt.digia.com/contact-us.
  1890. +** a written agreement between you and Nokia.
  1891.  **
  1892.  ** GNU Lesser General Public License Usage
  1893.  ** Alternatively, this file may be used under the terms of the GNU Lesser
  1894. @@ -22,8 +21,8 @@
  1895.  ** ensure the GNU Lesser General Public License version 2.1 requirements
  1896.  ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  1897.  **
  1898. -** In addition, as a special exception, Digia gives you certain additional
  1899. -** rights.  These rights are described in the Digia Qt LGPL Exception
  1900. +** In addition, as a special exception, Nokia gives you certain additional
  1901. +** rights.  These rights are described in the Nokia Qt LGPL Exception
  1902.  ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  1903.  **
  1904.  ** GNU General Public License Usage
  1905. @@ -34,7 +33,8 @@
  1906.  ** ensure the GNU General Public License version 3.0 requirements will be
  1907.  ** met: http://www.gnu.org/copyleft/gpl.html.
  1908.  **
  1909. -**
  1910. +** If you have questions regarding the use of this file, please contact
  1911. +** Nokia at qt-info@nokia.com.
  1912.  ** $QT_END_LICENSE$
  1913.  **
  1914.  ****************************************************************************/
  1915. @@ -78,7 +78,7 @@
  1916.  
  1917.  QThreadData::QThreadData(int initialRefCount)
  1918.      : _ref(initialRefCount), thread(0), threadId(0),
  1919. -      quitNow(false), loopLevel(0), eventDispatcher(0), canWait(true), isAdopted(false)
  1920. +      quitNow(false), loopLevel(0), eventDispatcher(0), canWait(true)
  1921.  {
  1922.      // fprintf(stderr, "QThreadData %p created\n", this);
  1923.  }
  1924. @@ -149,6 +149,9 @@
  1925.  
  1926.  QAdoptedThread::~QAdoptedThread()
  1927.  {
  1928. +#ifndef QT_NO_THREAD
  1929. +    QThreadPrivate::finish(this);
  1930. +#endif
  1931.      // fprintf(stderr, "~QAdoptedThread = %p\n", this);
  1932.  }
  1933.  
  1934. @@ -171,7 +174,6 @@
  1935.  
  1936.  QThreadPrivate::QThreadPrivate(QThreadData *d)
  1937.      : QObjectPrivate(), running(false), finished(false), terminated(false),
  1938. -      isInFinish(false), exited(false), returnCode(-1),
  1939.        stackSize(0), priority(QThread::InheritPriority), data(d)
  1940.  {
  1941.  #if defined (Q_OS_UNIX)
  1942. @@ -197,99 +199,58 @@
  1943.  
  1944.  /*!
  1945.      \class QThread
  1946. -    \brief The QThread class provides a platform-independent way to
  1947. -    manage threads.
  1948. +    \brief The QThread class provides platform-independent threads.
  1949.  
  1950.      \ingroup thread
  1951.  
  1952. -    A QThread object manages one thread of control within the
  1953. -    program. To make code run in a separate thread, simply create a
  1954. -    QThread, change the thread affinity of the QObject(s) that
  1955. -    contain the code, and start() the new event loop. For example:
  1956. +    A QThread represents a separate thread of control within the
  1957. +    program; it shares data with all the other threads within the
  1958. +    process but executes independently in the way that a separate
  1959. +    program does on a multitasking operating system. Instead of
  1960. +    starting in \c main(), QThreads begin executing in run().  By
  1961. +    default, run() starts the event loop by calling exec() (see
  1962. +    below). To create your own threads, subclass QThread and
  1963. +    reimplement run(). For example:
  1964.  
  1965.      \snippet doc/src/snippets/code/src_corelib_thread_qthread.cpp 0
  1966.  
  1967. -    The code inside the Worker's slot would then execute in a
  1968. -    separate thread. In this example, the QThread triggers the
  1969. -    Worker's doWork() slot upon starting, and frees the Worker's
  1970. -    memory upon terminating. However, you are free to connect the
  1971. -    Worker's slots to any signal, from any object, in any thread. It
  1972. -    is safe to connect signals and slots across different threads,
  1973. -    thanks to a mechanism called \l{Qt::QueuedConnection}{queued
  1974. -    connections}.
  1975. -
  1976. -    \note If you interact with an object, using any technique other
  1977. -    than queued signal/slot connections (e.g. direct function calls),
  1978. -    then the usual multithreading precautions need to be taken.
  1979. -
  1980. -    \note It is not possible to change the thread affinity of GUI
  1981. -    objects; they must remain in the main thread.
  1982. -
  1983. -
  1984. -    \section1 Managing threads
  1985. -
  1986. -    QThread will notifiy you via a signal
  1987. +    This will create a QTcpSocket in the thread and then execute the
  1988. +    thread's event loop. Use the start() method to begin execution.
  1989. +    Execution ends when you return from run(), just as an application
  1990. +    does when it leaves main(). QThread will notifiy you via a signal
  1991.      when the thread is started(), finished(), and terminated(), or
  1992.      you can use isFinished() and isRunning() to query the state of
  1993. -    the thread.
  1994. -
  1995. -    You can stop the thread by calling exit() or quit(). In extreme
  1996. -    cases, you may want to forcibly terminate() an executing thread.
  1997. -    However, doing so is dangerous and discouraged. Please read the
  1998. -    documentation for terminate() and setTerminationEnabled() for
  1999. -    detailed information.
  2000. -
  2001. -    From Qt 4.8 onwards, it is possible to deallocate objects that
  2002. -    live in a thread that has just ended, by connecting the
  2003. -    finished() signal to QObject::deleteLater().
  2004. +    the thread. Use wait() to block until the thread has finished
  2005. +    execution.
  2006.  
  2007. -    Use wait() to block the calling thread, until the other thread
  2008. -    has finished execution (or until a specified time has passed).
  2009. +    Each thread gets its own stack from the operating system. The
  2010. +    operating system also determines the default size of the stack.
  2011. +    You can use setStackSize() to set a custom stack size.
  2012. +
  2013. +    Each QThread can have its own event loop. You can start the event
  2014. +    loop by calling exec(); you can stop it by calling exit() or
  2015. +    quit(). Having an event loop in a thread makes it possible to
  2016. +    connect signals from other threads to slots in this thread, using
  2017. +    a mechanism called \l{Qt::QueuedConnection}{queued
  2018. +    connections}. It also makes it possible to use classes that
  2019. +    require the event loop, such as QTimer and QTcpSocket, in the
  2020. +    thread. Note, however, that it is not possible to use any widget
  2021. +    classes in the thread.
  2022. +
  2023. +    In extreme cases, you may want to forcibly terminate() an
  2024. +    executing thread. However, doing so is dangerous and discouraged.
  2025. +    Please read the documentation for terminate() and
  2026. +    setTerminationEnabled() for detailed information.
  2027.  
  2028.      The static functions currentThreadId() and currentThread() return
  2029.      identifiers for the currently executing thread. The former
  2030.      returns a platform specific ID for the thread; the latter returns
  2031.      a QThread pointer.
  2032.  
  2033. -
  2034. -    \section1 Subclassing QThread
  2035. -
  2036. -    Subclassing QThread is unnecessary for most purposes, since
  2037. -    QThread provides fully-functional thread management capabilities.
  2038. -    Nonetheless, QThread can be subclassed if you wish to implement
  2039. -    advanced thread management. This is done by adding new member
  2040. -    functions to the subclass, and/or by reimplementing run().
  2041. -    QThread's run() function is analogous to an application's main()
  2042. -    function -- it is executed when the thread is started, and the
  2043. -    thread will end when it returns.
  2044. -
  2045. -    \note Prior to Qt 4.4, the only way to use QThread for parallel
  2046. -    processing was to subclass it and implement the processing code
  2047. -    inside run(). This approach is now considered \b {bad practice};
  2048. -    a QThread should only manage a thread, not process data.
  2049. -
  2050. -    If you require event handling and signal/slot connections to
  2051. -    work in your thread, and if you reimplement run(), you must
  2052. -    explicitly call exec() at the end of your reimplementation:
  2053. -
  2054. -    \snippet doc/src/snippets/code/src_corelib_thread_qthread.cpp 1
  2055. -
  2056. -    QThread also provides static, platform independent sleep
  2057. -    functions: sleep(), msleep(), and usleep() allow full second,
  2058. -    millisecond, and microsecond resolution respectively.
  2059. -
  2060. -    \note wait() and the sleep() functions should be unnecessary in
  2061. -    general, since Qt is an event-driven framework. Instead of
  2062. -    wait(), consider listening for the finished() signal. Instead of
  2063. -    the sleep() functions, consider using QTimer.
  2064. -
  2065. -    It is important to remember that a QThread object usually lives
  2066. -    in the thread where it was created, not in the thread that it
  2067. -    manages. This oft-overlooked detail means that a QThread's slots
  2068. -    will be executed in the context of its home thread, not in the
  2069. -    context of the thread it is managing. For this reason,
  2070. -    implementing new slots in a QThread subclass is error-prone and
  2071. -    discouraged.
  2072. +    QThread also provides platform independent sleep functions in
  2073. +    varying resolutions. Use sleep() for full second resolution,
  2074. +    msleep() for millisecond resolution, and usleep() for microsecond
  2075. +    resolution.
  2076.  
  2077.      \sa {Thread Support in Qt}, QThreadStorage, QMutex, QSemaphore, QWaitCondition,
  2078.          {Mandelbrot Example}, {Semaphores Example}, {Wait Conditions Example}
  2079. @@ -330,7 +291,8 @@
  2080.  /*!
  2081.      \fn void QThread::start(Priority priority)
  2082.  
  2083. -    Begins execution of the thread by calling run(). The
  2084. +    Begins execution of the thread by calling run(), which should be
  2085. +    reimplemented in a QThread subclass to contain your code. The
  2086.      operating system will schedule the thread according to the \a
  2087.      priority parameter. If the thread is already running, this
  2088.      function does nothing.
  2089. @@ -393,7 +355,7 @@
  2090.  */
  2091.  
  2092.  /*!
  2093. -    Returns a pointer to a QThread which manages the currently
  2094. +    Returns a pointer to a QThread which represents the currently
  2095.      executing thread.
  2096.  */
  2097.  QThread *QThread::currentThread()
  2098. @@ -404,9 +366,8 @@
  2099.  }
  2100.  
  2101.  /*!
  2102. -    Constructs a new QThread to manage a new thread. The \a parent
  2103. -    takes ownership of the QThread. The thread does not begin
  2104. -    executing until start() is called.
  2105. +    Constructs a new thread with the given \a parent. The thread does
  2106. +    not begin executing until start() is called.
  2107.  
  2108.      \sa start()
  2109.  */
  2110. @@ -429,25 +390,20 @@
  2111.  }
  2112.  
  2113.  /*!
  2114. -    Destroys the QThread.
  2115. +    Destroys the thread.
  2116.  
  2117.      Note that deleting a QThread object will not stop the execution
  2118. -    of the thread it manages. Deleting a running QThread (i.e.
  2119. +    of the thread it represents. Deleting a running QThread (i.e.
  2120.      isFinished() returns false) will probably result in a program
  2121. -    crash. Wait for the finished() signal before deleting the
  2122. -    QThread.
  2123. +    crash. You can wait() on a thread to make sure that it has
  2124. +    finished.
  2125.  */
  2126.  QThread::~QThread()
  2127.  {
  2128.      Q_D(QThread);
  2129.      {
  2130.          QMutexLocker locker(&d->mutex);
  2131. -        if (d->isInFinish) {
  2132. -            locker.unlock();
  2133. -            wait();
  2134. -            locker.relock();
  2135. -        }
  2136. -        if (d->running && !d->finished && !d->data->isAdopted)
  2137. +        if (d->running && !d->finished)
  2138.              qWarning("QThread: Destroyed while thread is still running");
  2139.  
  2140.          d->data->thread = 0;
  2141. @@ -475,12 +431,6 @@
  2142.  {
  2143.      Q_D(const QThread);
  2144.      QMutexLocker locker(&d->mutex);
  2145. -#ifdef Q_OS_SYMBIAN
  2146. -    // app shutdown on Symbian can terminate threads and invalidate their stacks without notification,
  2147. -    // check the thread is still alive.
  2148. -    if (d->data->symbian_thread_handle.Handle() && d->data->symbian_thread_handle.ExitType() != EExitPending)
  2149. -        return false;
  2150. -#endif
  2151.      return d->running;
  2152.  }
  2153.  
  2154. @@ -532,18 +482,9 @@
  2155.      Q_D(QThread);
  2156.      QMutexLocker locker(&d->mutex);
  2157.      d->data->quitNow = false;
  2158. -    if (d->exited) {
  2159. -        d->exited = false;
  2160. -        return d->returnCode;
  2161. -    }
  2162. -    locker.unlock();
  2163. -
  2164.      QEventLoop eventLoop;
  2165. +    locker.unlock();
  2166.      int returnCode = eventLoop.exec();
  2167. -
  2168. -    locker.relock();
  2169. -    d->exited = false;
  2170. -    d->returnCode = -1;
  2171.      return returnCode;
  2172.  }
  2173.  
  2174. @@ -561,10 +502,8 @@
  2175.      function \e does return to the caller -- it is event processing
  2176.      that stops.
  2177.      
  2178. -    No QEventLoops will be started anymore in this thread  until
  2179. -    QThread::exec() has been called again. If the eventloop in QThread::exec()
  2180. -    is not running then the next call to QThread::exec() will also return
  2181. -    immediately.
  2182. +    This function does nothing if the thread does not have an event
  2183. +    loop.
  2184.  
  2185.      \sa quit() QEventLoop
  2186.  */
  2187. @@ -572,8 +511,6 @@
  2188.  {
  2189.      Q_D(QThread);
  2190.      QMutexLocker locker(&d->mutex);
  2191. -    d->exited = true;
  2192. -    d->returnCode = returnCode;
  2193.      d->data->quitNow = true;
  2194.      for (int i = 0; i < d->data->eventLoops.size(); ++i) {
  2195.          QEventLoop *eventLoop = d->data->eventLoops.at(i);
  2196. @@ -598,9 +535,9 @@
  2197.      newly created thread calls this function. The default
  2198.      implementation simply calls exec().
  2199.  
  2200. -    You can reimplement this function to facilitate advanced thread
  2201. -    management. Returning from this method will end the execution of
  2202. -    the thread.
  2203. +    You can reimplemented this function to do other useful
  2204. +    work. Returning from this method will end the execution of the
  2205. +    thread.
  2206.  
  2207.      \sa start() wait()
  2208.  */
  2209. @@ -680,9 +617,7 @@
  2210.  {
  2211.      Q_D(const QThread);
  2212.      QMutexLocker locker(&d->mutex);
  2213. -
  2214. -    // mask off the high bits that are used for flags
  2215. -    return Priority(d->priority & 0xffff);
  2216. +    return d->priority;
  2217.  }
  2218.  
  2219.  /*!
  2220. @@ -696,7 +631,7 @@
  2221.  /*!
  2222.      \fn void QThread::msleep(unsigned long msecs)
  2223.  
  2224. -    Forces the current thread to sleep for \a msecs milliseconds.
  2225. +    Causes the current thread to sleep for \a msecs milliseconds.
  2226.  
  2227.      \sa sleep(), usleep()
  2228.  */
  2229. @@ -704,7 +639,7 @@
  2230.  /*!
  2231.      \fn void QThread::usleep(unsigned long usecs)
  2232.  
  2233. -    Forces the current thread to sleep for \a usecs microseconds.
  2234. +    Causes the current thread to sleep for \a usecs microseconds.
  2235.  
  2236.      \sa sleep(), msleep()
  2237.  */
  2238. @@ -713,17 +648,17 @@
  2239.      \fn void QThread::terminate()
  2240.  
  2241.      Terminates the execution of the thread. The thread may or may not
  2242. -    be terminated immediately, depending on the operating system's
  2243. -    scheduling policies. Listen for the terminated() signal, or use
  2244. -    QThread::wait() after terminate(), to be sure.
  2245. +    be terminated immediately, depending on the operating systems
  2246. +    scheduling policies. Use QThread::wait() after terminate() for
  2247. +    synchronous termination.
  2248.  
  2249.      When the thread is terminated, all threads waiting for the thread
  2250.      to finish will be woken up.
  2251.  
  2252.      \warning This function is dangerous and its use is discouraged.
  2253. -    The thread can be terminated at any point in its code path.
  2254. +    The thread can be terminate at any point in its code path.
  2255.      Threads can be terminated while modifying data. There is no
  2256. -    chance for the thread to clean up after itself, unlock any held
  2257. +    chance for the thread to cleanup after itself, unlock any held
  2258.      mutexes, etc. In short, use this function only if absolutely
  2259.      necessary.
  2260.  
  2261. 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
  2262. --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qthread.h   2012-11-23 14:09:55.000000000 +0400
  2263. +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qthread.h   2011-06-23 11:45:00.000000000 +0400
  2264. @@ -1,18 +1,17 @@
  2265.  /****************************************************************************
  2266.  **
  2267. -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
  2268. -** Contact: http://www.qt-project.org/legal
  2269. +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
  2270. +** All rights reserved.
  2271. +** Contact: Nokia Corporation (qt-info@nokia.com)
  2272.  **
  2273.  ** This file is part of the QtCore module of the Qt Toolkit.
  2274.  **
  2275.  ** $QT_BEGIN_LICENSE:LGPL$
  2276. -** Commercial License Usage
  2277. -** Licensees holding valid commercial Qt licenses may use this file in
  2278. -** accordance with the commercial license agreement provided with the
  2279. +** Commercial Usage
  2280. +** Licensees holding valid Qt Commercial licenses may use this file in
  2281. +** accordance with the Qt Commercial License Agreement provided with the
  2282.  ** Software or, alternatively, in accordance with the terms contained in
  2283. -** a written agreement between you and Digia.  For licensing terms and
  2284. -** conditions see http://qt.digia.com/licensing.  For further information
  2285. -** use the contact form at http://qt.digia.com/contact-us.
  2286. +** a written agreement between you and Nokia.
  2287.  **
  2288.  ** GNU Lesser General Public License Usage
  2289.  ** Alternatively, this file may be used under the terms of the GNU Lesser
  2290. @@ -22,8 +21,8 @@
  2291.  ** ensure the GNU Lesser General Public License version 2.1 requirements
  2292.  ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  2293.  **
  2294. -** In addition, as a special exception, Digia gives you certain additional
  2295. -** rights.  These rights are described in the Digia Qt LGPL Exception
  2296. +** In addition, as a special exception, Nokia gives you certain additional
  2297. +** rights.  These rights are described in the Nokia Qt LGPL Exception
  2298.  ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  2299.  **
  2300.  ** GNU General Public License Usage
  2301. @@ -34,7 +33,8 @@
  2302.  ** ensure the GNU General Public License version 3.0 requirements will be
  2303.  ** met: http://www.gnu.org/copyleft/gpl.html.
  2304.  **
  2305. -**
  2306. +** If you have questions regarding the use of this file, please contact
  2307. +** Nokia at qt-info@nokia.com.
  2308.  ** $QT_END_LICENSE$
  2309.  **
  2310.  ****************************************************************************/
  2311. 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
  2312. --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qthread_p.h 2012-11-23 14:09:55.000000000 +0400
  2313. +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qthread_p.h 2013-02-14 21:06:00.000000000 +0400
  2314. @@ -1,18 +1,17 @@
  2315.  /****************************************************************************
  2316.  **
  2317. -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
  2318. -** Contact: http://www.qt-project.org/legal
  2319. +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
  2320. +** All rights reserved.
  2321. +** Contact: Nokia Corporation (qt-info@nokia.com)
  2322.  **
  2323.  ** This file is part of the QtCore module of the Qt Toolkit.
  2324.  **
  2325.  ** $QT_BEGIN_LICENSE:LGPL$
  2326. -** Commercial License Usage
  2327. -** Licensees holding valid commercial Qt licenses may use this file in
  2328. -** accordance with the commercial license agreement provided with the
  2329. +** Commercial Usage
  2330. +** Licensees holding valid Qt Commercial licenses may use this file in
  2331. +** accordance with the Qt Commercial License Agreement provided with the
  2332.  ** Software or, alternatively, in accordance with the terms contained in
  2333. -** a written agreement between you and Digia.  For licensing terms and
  2334. -** conditions see http://qt.digia.com/licensing.  For further information
  2335. -** use the contact form at http://qt.digia.com/contact-us.
  2336. +** a written agreement between you and Nokia.
  2337.  **
  2338.  ** GNU Lesser General Public License Usage
  2339.  ** Alternatively, this file may be used under the terms of the GNU Lesser
  2340. @@ -22,8 +21,8 @@
  2341.  ** ensure the GNU Lesser General Public License version 2.1 requirements
  2342.  ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  2343.  **
  2344. -** In addition, as a special exception, Digia gives you certain additional
  2345. -** rights.  These rights are described in the Digia Qt LGPL Exception
  2346. +** In addition, as a special exception, Nokia gives you certain additional
  2347. +** rights.  These rights are described in the Nokia Qt LGPL Exception
  2348.  ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  2349.  **
  2350.  ** GNU General Public License Usage
  2351. @@ -34,7 +33,8 @@
  2352.  ** ensure the GNU General Public License version 3.0 requirements will be
  2353.  ** met: http://www.gnu.org/copyleft/gpl.html.
  2354.  **
  2355. -**
  2356. +** If you have questions regarding the use of this file, please contact
  2357. +** Nokia at qt-info@nokia.com.
  2358.  ** $QT_END_LICENSE$
  2359.  **
  2360.  ****************************************************************************/
  2361. @@ -93,8 +93,6 @@
  2362.      return priority < pe.priority;
  2363.  }
  2364.  
  2365. -// This class holds the list of posted events.
  2366. -//  The list has to be kept sorted by priority
  2367.  class QPostEventList : public QList<QPostEvent>
  2368.  {
  2369.  public:
  2370. @@ -133,7 +131,6 @@
  2371.  };
  2372.  
  2373.  #ifndef QT_NO_THREAD
  2374. -
  2375.  class QThreadPrivate : public QObjectPrivate
  2376.  {
  2377.      Q_DECLARE_PUBLIC(QThread)
  2378. @@ -147,10 +144,6 @@
  2379.      bool running;
  2380.      bool finished;
  2381.      bool terminated;
  2382. -    bool isInFinish; //when in QThreadPrivate::finish
  2383. -
  2384. -    bool exited;
  2385. -    int returnCode;
  2386.  
  2387.      uint stackSize;
  2388.      QThread::Priority priority;
  2389. @@ -167,7 +160,6 @@
  2390.  #else
  2391.      static void finish(void *);
  2392.  #endif
  2393. -
  2394.  #endif // Q_OS_UNIX
  2395.  
  2396.  #if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
  2397. @@ -231,7 +223,8 @@
  2398.      QPostEventList postEventList;
  2399.      bool canWait;
  2400.      QVector<void *> tls;
  2401. -    bool isAdopted;
  2402. +
  2403. +    QMutex mutex;
  2404.  
  2405.  # ifdef Q_OS_SYMBIAN
  2406.      RThread symbian_thread_handle;
  2407. 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
  2408. --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qthreadstorage.cpp  2012-11-23 14:09:55.000000000 +0400
  2409. +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qthreadstorage.cpp  2011-06-23 11:45:00.000000000 +0400
  2410. @@ -1,18 +1,17 @@
  2411.  /****************************************************************************
  2412.  **
  2413. -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
  2414. -** Contact: http://www.qt-project.org/legal
  2415. +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
  2416. +** All rights reserved.
  2417. +** Contact: Nokia Corporation (qt-info@nokia.com)
  2418.  **
  2419.  ** This file is part of the QtCore module of the Qt Toolkit.
  2420.  **
  2421.  ** $QT_BEGIN_LICENSE:LGPL$
  2422. -** Commercial License Usage
  2423. -** Licensees holding valid commercial Qt licenses may use this file in
  2424. -** accordance with the commercial license agreement provided with the
  2425. +** Commercial Usage
  2426. +** Licensees holding valid Qt Commercial licenses may use this file in
  2427. +** accordance with the Qt Commercial License Agreement provided with the
  2428.  ** Software or, alternatively, in accordance with the terms contained in
  2429. -** a written agreement between you and Digia.  For licensing terms and
  2430. -** conditions see http://qt.digia.com/licensing.  For further information
  2431. -** use the contact form at http://qt.digia.com/contact-us.
  2432. +** a written agreement between you and Nokia.
  2433.  **
  2434.  ** GNU Lesser General Public License Usage
  2435.  ** Alternatively, this file may be used under the terms of the GNU Lesser
  2436. @@ -22,8 +21,8 @@
  2437.  ** ensure the GNU Lesser General Public License version 2.1 requirements
  2438.  ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  2439.  **
  2440. -** In addition, as a special exception, Digia gives you certain additional
  2441. -** rights.  These rights are described in the Digia Qt LGPL Exception
  2442. +** In addition, as a special exception, Nokia gives you certain additional
  2443. +** rights.  These rights are described in the Nokia Qt LGPL Exception
  2444.  ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  2445.  **
  2446.  ** GNU General Public License Usage
  2447. @@ -34,7 +33,8 @@
  2448.  ** ensure the GNU General Public License version 3.0 requirements will be
  2449.  ** met: http://www.gnu.org/copyleft/gpl.html.
  2450.  **
  2451. -**
  2452. +** If you have questions regarding the use of this file, please contact
  2453. +** Nokia at qt-info@nokia.com.
  2454.  ** $QT_END_LICENSE$
  2455.  **
  2456.  ****************************************************************************/
  2457. @@ -79,21 +79,6 @@
  2458.  {
  2459.      QMutexLocker locker(mutex());
  2460.      DestructorMap *destr = destructors();
  2461. -    if (!destr) {
  2462. -        /*
  2463. -         the destructors vector has already been destroyed, yet a new
  2464. -         QThreadStorage is being allocated. this can only happen during global
  2465. -         destruction, at which point we assume that there is only one thread.
  2466. -         in order to keep QThreadStorage working, we need somewhere to store
  2467. -         the data, best place we have in this situation is at the tail of the
  2468. -         current thread's tls vector. the destructor is ignored, since we have
  2469. -         no where to store it, and no way to actually call it.
  2470. -         */
  2471. -        QThreadData *data = QThreadData::current();
  2472. -        id = data->tls.count();
  2473. -        DEBUG_MSG("QThreadStorageData: Allocated id %d, destructor %p cannot be stored", id, func);
  2474. -        return;
  2475. -    }
  2476.      for (id = 0; id < destr->count(); id++) {
  2477.          if (destr->at(id) == 0)
  2478.              break;
  2479. @@ -154,14 +139,12 @@
  2480.                  data->thread);
  2481.  
  2482.          QMutexLocker locker(mutex());
  2483. -        DestructorMap *destr = destructors();
  2484. -        void (*destructor)(void *) = destr ? destr->value(id) : 0;
  2485. +        void (*destructor)(void *) = destructors()->value(id);
  2486.          locker.unlock();
  2487.  
  2488.          void *q = value;
  2489.          value = 0;
  2490.  
  2491. -        if (destructor)
  2492.              destructor(q);
  2493.      }
  2494.  
  2495. @@ -178,12 +161,11 @@
  2496.          return; // nothing to do
  2497.  
  2498.      DEBUG_MSG("QThreadStorageData: Destroying storage for thread %p", QThread::currentThread());
  2499. -    while (!tls->isEmpty()) {
  2500. -        void *&value = tls->last();
  2501. +
  2502. +    for(int i = tls->size() - 1; i >= 0; i--) {
  2503. +        void *&value = (*tls)[i];
  2504.          void *q = value;
  2505.          value = 0;
  2506. -        int i = tls->size() - 1;
  2507. -        tls->resize(i);
  2508.  
  2509.          if (!q) {
  2510.              // data already deleted
  2511. @@ -201,11 +183,6 @@
  2512.              continue;
  2513.          }
  2514.          destructor(q); //crash here might mean the thread exited after qthreadstorage was destroyed
  2515. -
  2516. -        if (tls->size() > i) {
  2517. -            //re reset the tls in case it has been recreated by its own destructor.
  2518. -            (*tls)[i] = 0;
  2519. -        }
  2520.      }
  2521.      tls->clear();
  2522.  }
  2523. @@ -221,18 +198,19 @@
  2524.      QThreadStorage is a template class that provides per-thread data
  2525.      storage.
  2526.  
  2527. +    \e{Note that due to compiler limitations, QThreadStorage can only
  2528. +    store pointers.}
  2529. +
  2530.      The setLocalData() function stores a single thread-specific value
  2531.      for the calling thread. The data can be accessed later using
  2532. -    localData().
  2533. +    localData(). QThreadStorage takes ownership of the data (which
  2534. +    must be created on the heap with \c new) and deletes it when the
  2535. +    thread exits, either normally or via termination.
  2536.  
  2537.      The hasLocalData() function allows the programmer to determine if
  2538.      data has previously been set using the setLocalData() function.
  2539.      This is also useful for lazy initializiation.
  2540.  
  2541. -    If T is a pointer type, QThreadStorage takes ownership of the data
  2542. -    (which must be created on the heap with \c new) and deletes it when
  2543. -    the thread exits, either normally or via termination.
  2544. -
  2545.      For example, the following code uses QThreadStorage to store a
  2546.      single cache for each thread that calls the cacheObject() and
  2547.      removeFromCache() functions. The cache is automatically
  2548. @@ -246,6 +224,9 @@
  2549.  
  2550.      \list
  2551.  
  2552. +    \o As noted above, QThreadStorage can only store pointers due to
  2553. +    compiler limitations.
  2554. +
  2555.      \o The QThreadStorage destructor does not delete per-thread data.
  2556.      QThreadStorage only deletes per-thread data when the thread exits
  2557.      or when setLocalData() is called multiple times.
  2558. @@ -281,11 +262,8 @@
  2559.  /*!
  2560.      \fn bool QThreadStorage::hasLocalData() const
  2561.  
  2562. -    If T is a pointer type, returns true if the calling thread has
  2563. -    non-zero data available.
  2564. -
  2565. -    If T is a value type, returns whether the data has already been
  2566. -    constructed by calling setLocalData or localData.
  2567. +    Returns true if the calling thread has non-zero data available;
  2568. +    otherwise returns false.
  2569.  
  2570.      \sa localData()
  2571.  */
  2572. @@ -296,8 +274,10 @@
  2573.      Returns a reference to the data that was set by the calling
  2574.      thread.
  2575.  
  2576. -    If no data has been set, this will create a default constructed
  2577. -    instance of type T.
  2578. +    Note: QThreadStorage can only store pointers. This function
  2579. +    returns a reference to the pointer that was set by the calling
  2580. +    thread. The value of this reference is 0 if no data was set by
  2581. +    the calling thread,
  2582.  
  2583.      \sa hasLocalData()
  2584.  */
  2585. @@ -308,6 +288,10 @@
  2586.  
  2587.      Returns a copy of the data that was set by the calling thread.
  2588.  
  2589. +    Note: QThreadStorage can only store pointers. This function
  2590. +    returns a pointer to the data that was set by the calling thread.
  2591. +    If no data was set by the calling thread, this function returns 0.
  2592. +
  2593.      \sa hasLocalData()
  2594.  */
  2595.  
  2596. @@ -317,9 +301,19 @@
  2597.      Sets the local data for the calling thread to \a data. It can be
  2598.      accessed later using the localData() functions.
  2599.  
  2600. -    If T is a pointer type, QThreadStorage takes ownership of the data
  2601. -    and deletes it automatically either when the thread exits (either
  2602. -    normally or via termination) or when setLocalData() is called again.
  2603. +    If \a data is 0, this function deletes the previous data (if
  2604. +    any) and returns immediately.
  2605. +
  2606. +    If \a data is non-zero, QThreadStorage takes ownership of the \a
  2607. +    data and deletes it automatically either when the thread exits
  2608. +    (either normally or via termination) or when setLocalData() is
  2609. +    called again.
  2610. +
  2611. +    Note: QThreadStorage can only store pointers. The \a data
  2612. +    argument must be either a pointer to an object created on the heap
  2613. +    (i.e. using \c new) or 0. You should not delete \a data
  2614. +    yourself; QThreadStorage takes ownership and will delete the \a
  2615. +    data itself.
  2616.  
  2617.      \sa localData(), hasLocalData()
  2618.  */
  2619. 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
  2620. --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qthreadstorage.h    2012-11-23 14:09:55.000000000 +0400
  2621. +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qthreadstorage.h    2011-06-23 11:45:00.000000000 +0400
  2622. @@ -1,18 +1,17 @@
  2623.  /****************************************************************************
  2624.  **
  2625. -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
  2626. -** Contact: http://www.qt-project.org/legal
  2627. +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
  2628. +** All rights reserved.
  2629. +** Contact: Nokia Corporation (qt-info@nokia.com)
  2630.  **
  2631.  ** This file is part of the QtCore module of the Qt Toolkit.
  2632.  **
  2633.  ** $QT_BEGIN_LICENSE:LGPL$
  2634. -** Commercial License Usage
  2635. -** Licensees holding valid commercial Qt licenses may use this file in
  2636. -** accordance with the commercial license agreement provided with the
  2637. +** Commercial Usage
  2638. +** Licensees holding valid Qt Commercial licenses may use this file in
  2639. +** accordance with the Qt Commercial License Agreement provided with the
  2640.  ** Software or, alternatively, in accordance with the terms contained in
  2641. -** a written agreement between you and Digia.  For licensing terms and
  2642. -** conditions see http://qt.digia.com/licensing.  For further information
  2643. -** use the contact form at http://qt.digia.com/contact-us.
  2644. +** a written agreement between you and Nokia.
  2645.  **
  2646.  ** GNU Lesser General Public License Usage
  2647.  ** Alternatively, this file may be used under the terms of the GNU Lesser
  2648. @@ -22,8 +21,8 @@
  2649.  ** ensure the GNU Lesser General Public License version 2.1 requirements
  2650.  ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  2651.  **
  2652. -** In addition, as a special exception, Digia gives you certain additional
  2653. -** rights.  These rights are described in the Digia Qt LGPL Exception
  2654. +** In addition, as a special exception, Nokia gives you certain additional
  2655. +** rights.  These rights are described in the Nokia Qt LGPL Exception
  2656.  ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  2657.  **
  2658.  ** GNU General Public License Usage
  2659. @@ -34,7 +33,8 @@
  2660.  ** ensure the GNU General Public License version 3.0 requirements will be
  2661.  ** met: http://www.gnu.org/copyleft/gpl.html.
  2662.  **
  2663. -**
  2664. +** If you have questions regarding the use of this file, please contact
  2665. +** Nokia at qt-info@nokia.com.
  2666.  ** $QT_END_LICENSE$
  2667.  **
  2668.  ****************************************************************************/
  2669. @@ -91,10 +91,7 @@
  2670.  void qThreadStorage_setLocalData(QThreadStorageData &d, T **t)
  2671.  { (void) d.set(*t); }
  2672.  
  2673. -template <typename T>
  2674. -inline
  2675. -void qThreadStorage_deleteData(void *d, T **)
  2676. -{ delete static_cast<T *>(d); }
  2677. +#ifndef QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION
  2678.  
  2679.  // value-based specialization
  2680.  template <typename T>
  2681. @@ -119,11 +116,7 @@
  2682.  void qThreadStorage_setLocalData(QThreadStorageData &d, T *t)
  2683.  { (void) d.set(new T(*t)); }
  2684.  
  2685. -template <typename T>
  2686. -inline
  2687. -void qThreadStorage_deleteData(void *d, T *)
  2688. -{ delete static_cast<T *>(d); }
  2689. -
  2690. +#endif // QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION
  2691.  
  2692.  // MOC_SKIP_END
  2693.  #endif
  2694. @@ -137,7 +130,7 @@
  2695.      Q_DISABLE_COPY(QThreadStorage)
  2696.  
  2697.      static inline void deleteData(void *x)
  2698. -    { qThreadStorage_deleteData(x, reinterpret_cast<T*>(0)); }
  2699. +    { delete static_cast<T>(x); }
  2700.  
  2701.  public:
  2702.      inline QThreadStorage() : d(deleteData) { }
  2703. 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
  2704. --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qthread_symbian.cpp 2012-11-23 14:09:55.000000000 +0400
  2705. +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qthread_symbian.cpp 1970-01-01 03:00:00.000000000 +0300
  2706. @@ -1,698 +0,0 @@
  2707. -/****************************************************************************
  2708. -**
  2709. -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
  2710. -** Contact: http://www.qt-project.org/legal
  2711. -**
  2712. -** This file is part of the QtCore module of the Qt Toolkit.
  2713. -**
  2714. -** $QT_BEGIN_LICENSE:LGPL$
  2715. -** Commercial License Usage
  2716. -** Licensees holding valid commercial Qt licenses may use this file in
  2717. -** accordance with the commercial license agreement provided with the
  2718. -** Software or, alternatively, in accordance with the terms contained in
  2719. -** a written agreement between you and Digia.  For licensing terms and
  2720. -** conditions see http://qt.digia.com/licensing.  For further information
  2721. -** use the contact form at http://qt.digia.com/contact-us.
  2722. -**
  2723. -** GNU Lesser General Public License Usage
  2724. -** Alternatively, this file may be used under the terms of the GNU Lesser
  2725. -** General Public License version 2.1 as published by the Free Software
  2726. -** Foundation and appearing in the file LICENSE.LGPL included in the
  2727. -** packaging of this file.  Please review the following information to
  2728. -** ensure the GNU Lesser General Public License version 2.1 requirements
  2729. -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  2730. -**
  2731. -** In addition, as a special exception, Digia gives you certain additional
  2732. -** rights.  These rights are described in the Digia Qt LGPL Exception
  2733. -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  2734. -**
  2735. -** GNU General Public License Usage
  2736. -** Alternatively, this file may be used under the terms of the GNU
  2737. -** General Public License version 3.0 as published by the Free Software
  2738. -** Foundation and appearing in the file LICENSE.GPL included in the
  2739. -** packaging of this file.  Please review the following information to
  2740. -** ensure the GNU General Public License version 3.0 requirements will be
  2741. -** met: http://www.gnu.org/copyleft/gpl.html.
  2742. -**
  2743. -**
  2744. -** $QT_END_LICENSE$
  2745. -**
  2746. -****************************************************************************/
  2747. -
  2748. -#include "qthread.h"
  2749. -#include "qplatformdefs.h"
  2750. -#include <private/qcoreapplication_p.h>
  2751. -#include <private/qeventdispatcher_symbian_p.h>
  2752. -#include "qthreadstorage.h"
  2753. -#include "qthread_p.h"
  2754. -#include <private/qsystemerror_p.h>
  2755. -#include <private/qcore_symbian_p.h>
  2756. -
  2757. -#include <sched.h>
  2758. -#include <hal.h>
  2759. -#include <hal_data.h>
  2760. -#include <e32math.h>
  2761. -
  2762. -#include <QRegExp>
  2763. -// This can be manually enabled if debugging thread problems
  2764. -#ifdef QT_USE_RTTI_IN_THREAD_CLASSNAME
  2765. -#include <typeinfo>
  2766. -#endif
  2767. -
  2768. -// You only find these enumerations on Symbian^3 onwards, so we need to provide our own
  2769. -// to remain compatible with older releases. They won't be called by pre-Sym^3 SDKs.
  2770. -
  2771. -// HALData::ENumCpus
  2772. -#define QT_HALData_ENumCpus 119
  2773. -
  2774. -QT_BEGIN_NAMESPACE
  2775. -
  2776. -#ifndef QT_NO_THREAD
  2777. -
  2778. -enum { ThreadPriorityResetFlag = 0x80000000 };
  2779. -
  2780. -// Utility functions for getting, setting and clearing thread specific data.
  2781. -static QThreadData *get_thread_data()
  2782. -{
  2783. -    return reinterpret_cast<QThreadData *>(Dll::Tls());
  2784. -}
  2785. -
  2786. -static void set_thread_data(QThreadData *data)
  2787. -{
  2788. -    qt_symbian_throwIfError(Dll::SetTls(data));
  2789. -}
  2790. -
  2791. -static void clear_thread_data()
  2792. -{
  2793. -    Dll::FreeTls();
  2794. -}
  2795. -
  2796. -
  2797. -static void init_symbian_thread_handle(RThread &thread)
  2798. -{
  2799. -    thread = RThread();
  2800. -    TThreadId threadId = thread.Id();
  2801. -    qt_symbian_throwIfError(thread.Open(threadId, EOwnerProcess));
  2802. -}
  2803. -
  2804. -QThreadData *QThreadData::current()
  2805. -{
  2806. -    QThreadData *data = get_thread_data();
  2807. -    if (!data) {
  2808. -        void *a;
  2809. -        if (QInternal::activateCallbacks(QInternal::AdoptCurrentThread, &a)) {
  2810. -            QThread *adopted = static_cast<QThread*>(a);
  2811. -            Q_ASSERT(adopted);
  2812. -            data = QThreadData::get2(adopted);
  2813. -            set_thread_data(data);
  2814. -            adopted->d_func()->running = true;
  2815. -            adopted->d_func()->finished = false;
  2816. -            static_cast<QAdoptedThread *>(adopted)->init();
  2817. -        } else {
  2818. -            data = new QThreadData;
  2819. -            QT_TRY {
  2820. -                set_thread_data(data);
  2821. -                data->thread = new QAdoptedThread(data);
  2822. -            } QT_CATCH(...) {
  2823. -                clear_thread_data();
  2824. -                data->deref();
  2825. -                data = 0;
  2826. -                QT_RETHROW;
  2827. -            }
  2828. -            data->deref();
  2829. -        }
  2830. -        data->isAdopted = true;
  2831. -        data->threadId = QThread::currentThreadId();
  2832. -        if (!QCoreApplicationPrivate::theMainThread)
  2833. -            QCoreApplicationPrivate::theMainThread = data->thread;
  2834. -    }
  2835. -    return data;
  2836. -}
  2837. -
  2838. -
  2839. -class QCAdoptedThreadMonitor : public CActive
  2840. -{
  2841. -public:
  2842. -    QCAdoptedThreadMonitor(QThread *thread)
  2843. -    : CActive(EPriorityStandard), data(QThreadData::get2(thread))
  2844. -    {
  2845. -        CActiveScheduler::Add(this);
  2846. -        data->symbian_thread_handle.Logon(iStatus);
  2847. -        SetActive();
  2848. -    }
  2849. -    ~QCAdoptedThreadMonitor()
  2850. -    {
  2851. -        Cancel();
  2852. -    }
  2853. -    void DoCancel()
  2854. -    {
  2855. -        data->symbian_thread_handle.LogonCancel(iStatus);
  2856. -    }
  2857. -    void RunL();
  2858. -private:
  2859. -    QThreadData* data;
  2860. -};
  2861. -
  2862. -class QCAddAdoptedThread : public CActive
  2863. -{
  2864. -public:
  2865. -    QCAddAdoptedThread()
  2866. -    : CActive(EPriorityStandard)
  2867. -    {
  2868. -        CActiveScheduler::Add(this);
  2869. -    }
  2870. -    void ConstructL()
  2871. -    {
  2872. -        User::LeaveIfError(monitorThread.Open(RThread().Id()));
  2873. -        start();
  2874. -    }
  2875. -    ~QCAddAdoptedThread()
  2876. -    {
  2877. -        Cancel();
  2878. -        monitorThread.Close();
  2879. -    }
  2880. -    void DoCancel()
  2881. -    {
  2882. -        User::RequestComplete(stat, KErrCancel);
  2883. -    }
  2884. -    void start()
  2885. -    {
  2886. -        iStatus = KRequestPending;
  2887. -        SetActive();
  2888. -        stat = &iStatus;
  2889. -    }
  2890. -    void RunL()
  2891. -    {
  2892. -        if (iStatus.Int() != KErrNone)
  2893. -            return;
  2894. -
  2895. -        QMutexLocker adoptedThreadMonitorMutexlock(&adoptedThreadMonitorMutex);
  2896. -        for (int i=threadsToAdd.size()-1; i>=0; i--) {
  2897. -            // Create an active object to monitor the thread
  2898. -            new (ELeave) QCAdoptedThreadMonitor(threadsToAdd[i]);
  2899. -            count++;
  2900. -            threadsToAdd.pop_back();
  2901. -        }
  2902. -        start();
  2903. -    }
  2904. -    static void add(QThread *thread)
  2905. -    {
  2906. -        QMutexLocker adoptedThreadMonitorMutexlock(&adoptedThreadMonitorMutex);
  2907. -        if (!adoptedThreadAdder) {
  2908. -            RThread monitorThread;
  2909. -            qt_symbian_throwIfError(monitorThread.Create(KNullDesC(), &monitorThreadFunc, 1024, &User::Allocator(), 0));
  2910. -            TRequestStatus started;
  2911. -            monitorThread.Rendezvous(started);
  2912. -            monitorThread.Resume();
  2913. -            User::WaitForRequest(started);
  2914. -            monitorThread.Close();
  2915. -        }
  2916. -        if (RThread().Id() == adoptedThreadAdder->monitorThread.Id())
  2917. -            return;
  2918. -        adoptedThreadAdder->threadsToAdd.push_back(thread);
  2919. -        if (adoptedThreadAdder->stat) {
  2920. -            adoptedThreadAdder->monitorThread.RequestComplete(adoptedThreadAdder->stat, KErrNone);
  2921. -        }
  2922. -    }
  2923. -    static void monitorThreadFuncL()
  2924. -    {
  2925. -        CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
  2926. -        CleanupStack::PushL(scheduler);
  2927. -        CActiveScheduler::Install(scheduler);
  2928. -
  2929. -        adoptedThreadAdder = new(ELeave) QCAddAdoptedThread();
  2930. -        CleanupStack::PushL(adoptedThreadAdder);
  2931. -        adoptedThreadAdder->ConstructL();
  2932. -        QCAddAdoptedThread *adder = adoptedThreadAdder;
  2933. -
  2934. -        RThread::Rendezvous(KErrNone);
  2935. -        CActiveScheduler::Start();
  2936. -
  2937. -        CleanupStack::PopAndDestroy(adder);
  2938. -        CleanupStack::PopAndDestroy(scheduler);
  2939. -    }
  2940. -    static int monitorThreadFunc(void *)
  2941. -    {
  2942. -        _LIT(KMonitorThreadName, "adoptedMonitorThread");
  2943. -        RThread::RenameMe(KMonitorThreadName());
  2944. -        CTrapCleanup* cleanup = CTrapCleanup::New();
  2945. -        TRAPD(ret, monitorThreadFuncL());
  2946. -        delete cleanup;
  2947. -        return ret;
  2948. -    }
  2949. -    static void threadDied()
  2950. -    {
  2951. -        QMutexLocker adoptedThreadMonitorMutexlock(&adoptedThreadMonitorMutex);
  2952. -        if (adoptedThreadAdder) {
  2953. -            adoptedThreadAdder->count--;
  2954. -            if (adoptedThreadAdder->count <= 0 && adoptedThreadAdder->threadsToAdd.size() == 0) {
  2955. -                CActiveScheduler::Stop();
  2956. -                adoptedThreadAdder = 0;
  2957. -            }
  2958. -        }
  2959. -    }
  2960. -
  2961. -private:
  2962. -    QVector<QThread*> threadsToAdd;
  2963. -    RThread monitorThread;
  2964. -    static QMutex adoptedThreadMonitorMutex;
  2965. -    static QCAddAdoptedThread *adoptedThreadAdder;
  2966. -    int count;
  2967. -    TRequestStatus *stat;
  2968. -};
  2969. -
  2970. -QMutex QCAddAdoptedThread::adoptedThreadMonitorMutex;
  2971. -QCAddAdoptedThread* QCAddAdoptedThread::adoptedThreadAdder = 0;
  2972. -
  2973. -static void finishAdoptedThread(QThreadData* data, bool closeNativeHandle)
  2974. -{
  2975. -    if (data->isAdopted) {
  2976. -        QThread *thread = data->thread;
  2977. -        Q_ASSERT(thread);
  2978. -        QThreadPrivate *thread_p = static_cast<QThreadPrivate *>(QObjectPrivate::get(thread));
  2979. -        if (!thread_p->finished)
  2980. -            thread_p->finish(thread, true, closeNativeHandle);
  2981. -        else if (closeNativeHandle && data->symbian_thread_handle.Handle())
  2982. -            data->symbian_thread_handle.Close();
  2983. -    }
  2984. -}
  2985. -
  2986. -void QCAdoptedThreadMonitor::RunL()
  2987. -{
  2988. -    // clean up the thread, or close the handle if that's all that's left
  2989. -    finishAdoptedThread(data, true);
  2990. -    data->deref();
  2991. -    QCAddAdoptedThread::threadDied();
  2992. -    delete this;
  2993. -}
  2994. -
  2995. -static pthread_once_t current_thread_data_once = PTHREAD_ONCE_INIT;
  2996. -static pthread_key_t current_thread_data_key;
  2997. -
  2998. -static void pthread_in_thread_cleanup(void *p)
  2999. -{
  3000. -    QThreadData *data = static_cast<QThreadData *>(p);
  3001. -    // clean up the thread, but leave the handle for adoptedThreadMonitor
  3002. -    finishAdoptedThread(data, false);
  3003. -}
  3004. -
  3005. -static void create_current_thread_data_key()
  3006. -{
  3007. -    pthread_key_create(&current_thread_data_key, pthread_in_thread_cleanup);
  3008. -}
  3009. -
  3010. -static void destroy_current_thread_data_key()
  3011. -{
  3012. -    pthread_once(&current_thread_data_once, create_current_thread_data_key);
  3013. -    pthread_key_delete(current_thread_data_key);
  3014. -}
  3015. -Q_DESTRUCTOR_FUNCTION(destroy_current_thread_data_key)
  3016. -
  3017. -void QAdoptedThread::init()
  3018. -{
  3019. -    Q_D(QThread);
  3020. -    d->thread_id = RThread().Id();  // type operator to TUint
  3021. -    init_symbian_thread_handle(d->data->symbian_thread_handle);
  3022. -    QCAddAdoptedThread::add(this);
  3023. -    pthread_once(&current_thread_data_once, create_current_thread_data_key);
  3024. -    pthread_setspecific(current_thread_data_key, get_thread_data());
  3025. -}
  3026. -
  3027. -/*
  3028. -   QThreadPrivate
  3029. -*/
  3030. -
  3031. -#if defined(Q_C_CALLBACKS)
  3032. -extern "C" {
  3033. -#endif
  3034. -
  3035. -typedef void*(*QtThreadCallback)(void*);
  3036. -
  3037. -#if defined(Q_C_CALLBACKS)
  3038. -}
  3039. -#endif
  3040. -
  3041. -#endif // QT_NO_THREAD
  3042. -
  3043. -void QThreadPrivate::createEventDispatcher(QThreadData *data)
  3044. -{
  3045. -    data->eventDispatcher = new QEventDispatcherSymbian;
  3046. -    data->eventDispatcher->startingUp();
  3047. -}
  3048. -
  3049. -#ifndef QT_NO_THREAD
  3050. -
  3051. -void *QThreadPrivate::start(void *arg)
  3052. -{
  3053. -    QThread *thr = reinterpret_cast<QThread *>(arg);
  3054. -    QThreadData *data = QThreadData::get2(thr);
  3055. -
  3056. -    // do we need to reset the thread priority?
  3057. -    if (int(thr->d_func()->priority) & ThreadPriorityResetFlag) {
  3058. -        thr->setPriority(QThread::Priority(thr->d_func()->priority & ~ThreadPriorityResetFlag));
  3059. -    }
  3060. -
  3061. -    // On symbian, threads other than the main thread are non critical by default
  3062. -    // This means a worker thread can crash without crashing the application - to
  3063. -    // use this feature, we would need to use RThread::Logon in the main thread
  3064. -    // to catch abnormal thread exit and emit the finished signal.
  3065. -    // For the sake of cross platform consistency, we set the thread as process critical
  3066. -    // - advanced users who want the symbian behaviour can change the critical
  3067. -    // attribute of the thread again once the app gains control in run()
  3068. -    User::SetCritical(User::EProcessCritical);
  3069. -
  3070. -    data->threadId = QThread::currentThreadId();
  3071. -    set_thread_data(data);
  3072. -
  3073. -    CTrapCleanup *cleanup = CTrapCleanup::New();
  3074. -    q_check_ptr(cleanup);
  3075. -
  3076. -    {
  3077. -        QMutexLocker locker(&thr->d_func()->mutex);
  3078. -        data->quitNow = thr->d_func()->exited;
  3079. -    }
  3080. -
  3081. -    // ### TODO: allow the user to create a custom event dispatcher
  3082. -    createEventDispatcher(data);
  3083. -
  3084. -    TRAPD(err, {
  3085. -        try {
  3086. -            emit thr->started();
  3087. -            thr->run();
  3088. -        } catch (const std::exception& ex) {
  3089. -            qWarning("QThreadPrivate::start: Thread exited on exception %s", ex.what());
  3090. -            User::Leave(KErrGeneral);   // leave to force cleanup stack cleanup
  3091. -        }
  3092. -    });
  3093. -    if (err)
  3094. -        qWarning("QThreadPrivate::start: Thread exited on leave %d", err);
  3095. -
  3096. -    // finish emits signals which should be wrapped in a trap for Symbian code, but otherwise ignore leaves and exceptions.
  3097. -    TRAP(err, {
  3098. -        try {
  3099. -            QThreadPrivate::finish(arg);
  3100. -        } catch (const std::exception& ex) {
  3101. -            User::Leave(KErrGeneral);   // leave to force cleanup stack cleanup
  3102. -        }
  3103. -    });
  3104. -
  3105. -    delete cleanup;
  3106. -
  3107. -    return 0;
  3108. -}
  3109. -
  3110. -void QThreadPrivate::finish(void *arg, bool lockAnyway, bool closeNativeHandle)
  3111. -{
  3112. -    QThread *thr = reinterpret_cast<QThread *>(arg);
  3113. -    QThreadPrivate *d = thr->d_func();
  3114. -
  3115. -    QMutexLocker locker(lockAnyway ? &d->mutex : 0);
  3116. -
  3117. -    d->isInFinish = true;
  3118. -    d->priority = QThread::InheritPriority;
  3119. -    bool terminated = d->terminated;
  3120. -    void *data = &d->data->tls;
  3121. -    locker.unlock();
  3122. -    if (terminated)
  3123. -        emit thr->terminated();
  3124. -    emit thr->finished();
  3125. -    QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
  3126. -    QThreadStorageData::finish((void **)data);
  3127. -    locker.relock();
  3128. -    d->terminated = false;
  3129. -
  3130. -    QAbstractEventDispatcher *eventDispatcher = d->data->eventDispatcher;
  3131. -    if (eventDispatcher) {
  3132. -        d->data->eventDispatcher = 0;
  3133. -        locker.unlock();
  3134. -        eventDispatcher->closingDown();
  3135. -        delete eventDispatcher;
  3136. -        locker.relock();
  3137. -    }
  3138. -
  3139. -    d->thread_id = 0;
  3140. -    if (closeNativeHandle)
  3141. -        d->data->symbian_thread_handle.Close();
  3142. -    d->running = false;
  3143. -    d->finished = true;
  3144. -
  3145. -    d->isInFinish = false;
  3146. -    d->thread_done.wakeAll();
  3147. -}
  3148. -
  3149. -
  3150. -
  3151. -
  3152. -/**************************************************************************
  3153. - ** QThread
  3154. - *************************************************************************/
  3155. -
  3156. -Qt::HANDLE QThread::currentThreadId()
  3157. -{
  3158. -    return (Qt::HANDLE) (TUint) RThread().Id();
  3159. -}
  3160. -
  3161. -int QThread::idealThreadCount()
  3162. -{
  3163. -    int cores = 1;
  3164. -
  3165. -    if (QSysInfo::symbianVersion() >= QSysInfo::SV_SF_3) {
  3166. -        TInt inumcpus;
  3167. -        TInt err;
  3168. -        err = HAL::Get((HALData::TAttribute)QT_HALData_ENumCpus, inumcpus);
  3169. -        if (err == KErrNone) {
  3170. -            cores = qMax(inumcpus, 1);
  3171. -        }
  3172. -    }
  3173. -
  3174. -    return cores;
  3175. -}
  3176. -
  3177. -void QThread::yieldCurrentThread()
  3178. -{
  3179. -    sched_yield();
  3180. -}
  3181. -
  3182. -/*  \internal
  3183. -    helper function to do thread sleeps
  3184. -*/
  3185. -static void thread_sleep(unsigned long remaining, unsigned long scale)
  3186. -{
  3187. -    // maximum Symbian wait is 2^31 microseconds
  3188. -    unsigned long maxWait = KMaxTInt / scale;
  3189. -    do {
  3190. -        unsigned long waitTime = qMin(maxWait, remaining);
  3191. -        remaining -= waitTime;
  3192. -        User::AfterHighRes(waitTime * scale);
  3193. -    } while (remaining);
  3194. -}
  3195. -
  3196. -void QThread::sleep(unsigned long secs)
  3197. -{
  3198. -    thread_sleep(secs, 1000000ul);
  3199. -}
  3200. -
  3201. -void QThread::msleep(unsigned long msecs)
  3202. -{
  3203. -    thread_sleep(msecs, 1000ul);
  3204. -}
  3205. -
  3206. -void QThread::usleep(unsigned long usecs)
  3207. -{
  3208. -    thread_sleep(usecs, 1ul);
  3209. -}
  3210. -
  3211. -TThreadPriority calculateSymbianPriority(QThread::Priority priority)
  3212. -    {
  3213. -    // Both Qt & Symbian use limited enums; this matches the mapping previously done through conversion to Posix granularity
  3214. -    TThreadPriority symPriority;
  3215. -    switch (priority)
  3216. -    {
  3217. -        case QThread::IdlePriority:
  3218. -            symPriority = EPriorityMuchLess;
  3219. -            break;
  3220. -        case QThread::LowestPriority:
  3221. -        case QThread::LowPriority:
  3222. -            symPriority = EPriorityLess;
  3223. -            break;
  3224. -        case QThread::NormalPriority:
  3225. -            symPriority = EPriorityNormal;
  3226. -            break;
  3227. -        case QThread::HighPriority:
  3228. -            symPriority = EPriorityMore;
  3229. -            break;
  3230. -        case QThread::HighestPriority:
  3231. -        case QThread::TimeCriticalPriority:
  3232. -            symPriority = EPriorityMuchMore;
  3233. -            break;
  3234. -        case QThread::InheritPriority:
  3235. -        default:
  3236. -            symPriority = RThread().Priority();
  3237. -            break;
  3238. -    }
  3239. -    return symPriority;
  3240. -    }
  3241. -
  3242. -void QThread::start(Priority priority)
  3243. -{
  3244. -    Q_D(QThread);
  3245. -    QMutexLocker locker(&d->mutex);
  3246. -
  3247. -    if (d->isInFinish)
  3248. -        d->thread_done.wait(locker.mutex());
  3249. -
  3250. -    if (d->running)
  3251. -        return;
  3252. -
  3253. -    d->running = true;
  3254. -    d->finished = false;
  3255. -    d->terminated = false;
  3256. -    d->returnCode = 0;
  3257. -    d->exited = false;
  3258. -
  3259. -    d->priority = priority;
  3260. -
  3261. -    if (d->stackSize == 0)
  3262. -        // The default stack size on Symbian is very small, making even basic
  3263. -        // operations like file I/O fail, so we increase it by default.
  3264. -        d->stackSize = 0x14000; // Maximum stack size on Symbian.
  3265. -
  3266. -    int code = KErrAlreadyExists;
  3267. -    QString className(QLatin1String(metaObject()->className()));
  3268. -#ifdef QT_USE_RTTI_IN_THREAD_CLASSNAME
  3269. -    // use RTTI, if enabled, to get a more accurate className. This must be manually enabled.
  3270. -    const char* rttiName = typeid(*this).name();
  3271. -    if (rttiName)
  3272. -        className = QLatin1String(rttiName);
  3273. -#endif
  3274. -    QString threadNameBase = QString(QLatin1String("%1_%2_v=0x%3_")).arg(objectName()).arg(className).arg(*(uint*)this,8,16,QLatin1Char('0'));
  3275. -    // Thread name can contain only characters allowed by User::ValidateName() otherwise RThread::Create fails.
  3276. -    // Not allowed characters are:
  3277. -    // - any character outside range 0x20 - 0x7e
  3278. -    // - or asterisk, question mark or colon
  3279. -    const QRegExp notAllowedChars(QLatin1String("[^\\x20-\\x7e]|\\*|\\?|\\:"));
  3280. -    threadNameBase.replace(notAllowedChars, QLatin1String("_"));
  3281. -
  3282. -    TPtrC threadNameBasePtr(qt_QString2TPtrC(threadNameBase));
  3283. -    // max thread name length is KMaxKernelName
  3284. -    TBuf<KMaxKernelName> name;
  3285. -    threadNameBasePtr.Set(threadNameBasePtr.Left(qMin(threadNameBasePtr.Length(), name.MaxLength() - 8)));
  3286. -    const int MaxRetries = 10;
  3287. -    for (int i=0; i<MaxRetries && code == KErrAlreadyExists; i++) {
  3288. -        // generate a thread name with a random component to avoid and resolve name collisions
  3289. -        // a named thread can be opened from another process
  3290. -        name.Zero();
  3291. -        name.Append(threadNameBasePtr);
  3292. -        name.AppendNumFixedWidth(Math::Random(), EHex, 8);
  3293. -        code = d->data->symbian_thread_handle.Create(name, (TThreadFunction) QThreadPrivate::start, d->stackSize, NULL, this);
  3294. -    }
  3295. -    if (code == KErrNone) {
  3296. -        d->thread_id = d->data->symbian_thread_handle.Id();
  3297. -        TThreadPriority symPriority = calculateSymbianPriority(priority);
  3298. -        d->data->symbian_thread_handle.SetPriority(symPriority);
  3299. -        d->data->symbian_thread_handle.Resume();
  3300. -    } else {
  3301. -        qWarning("QThread::start: Thread creation error: %s", qPrintable(QSystemError(code, QSystemError::NativeError).toString()));
  3302. -
  3303. -        d->running = false;
  3304. -        d->finished = false;
  3305. -        d->thread_id = 0;
  3306. -        d->data->symbian_thread_handle.Close();
  3307. -    }
  3308. -}
  3309. -
  3310. -void QThread::terminate()
  3311. -{
  3312. -    Q_D(QThread);
  3313. -    QMutexLocker locker(&d->mutex);
  3314. -
  3315. -    if (!d->thread_id)
  3316. -        return;
  3317. -
  3318. -    if (!d->running)
  3319. -        return;
  3320. -    if (!d->terminationEnabled) {
  3321. -        d->terminatePending = true;
  3322. -        return;
  3323. -    }
  3324. -
  3325. -    d->terminated = true;
  3326. -    // "false, false" meaning:
  3327. -    // 1. lockAnyway = false. Don't lock the mutex because it's already locked
  3328. -    //    (see above).
  3329. -    // 2. closeNativeSymbianHandle = false. We don't want to close the thread handle,
  3330. -    //    because we need it here to terminate the thread.
  3331. -    QThreadPrivate::finish(this, false, false);
  3332. -    d->data->symbian_thread_handle.Terminate(KErrNone);
  3333. -    d->data->symbian_thread_handle.Close();
  3334. -}
  3335. -
  3336. -bool QThread::wait(unsigned long time)
  3337. -{
  3338. -    Q_D(QThread);
  3339. -    QMutexLocker locker(&d->mutex);
  3340. -
  3341. -    if (d->thread_id == (TUint) RThread().Id()) {
  3342. -        qWarning("QThread::wait: Thread tried to wait on itself");
  3343. -        return false;
  3344. -    }
  3345. -
  3346. -    if (d->finished || !d->running)
  3347. -        return true;
  3348. -
  3349. -    while (d->running) {
  3350. -        // Check if thread still exists. Needed because kernel will kill it without notification
  3351. -        // before global statics are deleted at application exit.
  3352. -        if (d->data->symbian_thread_handle.Handle()
  3353. -            && d->data->symbian_thread_handle.ExitType() != EExitPending) {
  3354. -            // Cannot call finish here as wait is typically called from another thread.
  3355. -            // It won't be necessary anyway, as we should never get here under normal operations;
  3356. -            // all QThreads are EProcessCritical and therefore cannot normally exit
  3357. -            // undetected (i.e. panic) as long as all thread control is via QThread.
  3358. -            return true;
  3359. -        }
  3360. -        if (!d->thread_done.wait(locker.mutex(), time))
  3361. -            return false;
  3362. -    }
  3363. -    return true;
  3364. -}
  3365. -
  3366. -void QThread::setTerminationEnabled(bool enabled)
  3367. -{
  3368. -    QThread *thr = currentThread();
  3369. -    Q_ASSERT_X(thr != 0, "QThread::setTerminationEnabled()",
  3370. -               "Current thread was not started with QThread.");
  3371. -    QThreadPrivate *d = thr->d_func();
  3372. -    QMutexLocker locker(&d->mutex);
  3373. -    d->terminationEnabled = enabled;
  3374. -    if (enabled && d->terminatePending) {
  3375. -        d->terminated = true;
  3376. -        // "false" meaning:
  3377. -        // -  lockAnyway = false. Don't lock the mutex because it's already locked
  3378. -        //    (see above).
  3379. -        QThreadPrivate::finish(thr, false);
  3380. -        locker.unlock(); // don't leave the mutex locked!
  3381. -        User::Exit(0);  // may be some other cleanup required? what if AS or cleanup stack?
  3382. -    }
  3383. -}
  3384. -
  3385. -void QThread::setPriority(Priority priority)
  3386. -{
  3387. -    Q_D(QThread);
  3388. -    QMutexLocker locker(&d->mutex);
  3389. -    if (!d->running) {
  3390. -        qWarning("QThread::setPriority: Cannot set priority, thread is not running");
  3391. -        return;
  3392. -    }
  3393. -
  3394. -    d->priority = priority;
  3395. -
  3396. -    // copied from start() with a few modifications:
  3397. -    TThreadPriority symPriority = calculateSymbianPriority(priority);
  3398. -    d->data->symbian_thread_handle.SetPriority(symPriority);
  3399. -}
  3400. -
  3401. -#endif // QT_NO_THREAD
  3402. -
  3403. -QT_END_NAMESPACE
  3404. -
  3405. 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
  3406. --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qthread_unix.cpp    2012-11-23 14:09:55.000000000 +0400
  3407. +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qthread_unix.cpp    2013-02-14 21:08:00.000000000 +0400
  3408. @@ -1,18 +1,17 @@
  3409.  /****************************************************************************
  3410.  **
  3411. -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
  3412. -** Contact: http://www.qt-project.org/legal
  3413. +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
  3414. +** All rights reserved.
  3415. +** Contact: Nokia Corporation (qt-info@nokia.com)
  3416.  **
  3417.  ** This file is part of the QtCore module of the Qt Toolkit.
  3418.  **
  3419.  ** $QT_BEGIN_LICENSE:LGPL$
  3420. -** Commercial License Usage
  3421. -** Licensees holding valid commercial Qt licenses may use this file in
  3422. -** accordance with the commercial license agreement provided with the
  3423. +** Commercial Usage
  3424. +** Licensees holding valid Qt Commercial licenses may use this file in
  3425. +** accordance with the Qt Commercial License Agreement provided with the
  3426.  ** Software or, alternatively, in accordance with the terms contained in
  3427. -** a written agreement between you and Digia.  For licensing terms and
  3428. -** conditions see http://qt.digia.com/licensing.  For further information
  3429. -** use the contact form at http://qt.digia.com/contact-us.
  3430. +** a written agreement between you and Nokia.
  3431.  **
  3432.  ** GNU Lesser General Public License Usage
  3433.  ** Alternatively, this file may be used under the terms of the GNU Lesser
  3434. @@ -22,8 +21,8 @@
  3435.  ** ensure the GNU Lesser General Public License version 2.1 requirements
  3436.  ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  3437.  **
  3438. -** In addition, as a special exception, Digia gives you certain additional
  3439. -** rights.  These rights are described in the Digia Qt LGPL Exception
  3440. +** In addition, as a special exception, Nokia gives you certain additional
  3441. +** rights.  These rights are described in the Nokia Qt LGPL Exception
  3442.  ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  3443.  **
  3444.  ** GNU General Public License Usage
  3445. @@ -34,7 +33,8 @@
  3446.  ** ensure the GNU General Public License version 3.0 requirements will be
  3447.  ** met: http://www.gnu.org/copyleft/gpl.html.
  3448.  **
  3449. -**
  3450. +** If you have questions regarding the use of this file, please contact
  3451. +** Nokia at qt-info@nokia.com.
  3452.  ** $QT_END_LICENSE$
  3453.  **
  3454.  ****************************************************************************/
  3455. @@ -44,14 +44,14 @@
  3456.  #include "qplatformdefs.h"
  3457.  
  3458.  #include <private/qcoreapplication_p.h>
  3459. +#if !defined(QT_NO_GLIB)
  3460. +#  include "../kernel/qeventdispatcher_glib_p.h"
  3461. +#endif
  3462.  
  3463. -#if defined(Q_OS_BLACKBERRY)
  3464. -#  include <private/qeventdispatcher_blackberry_p.h>
  3465. +#ifdef Q_OS_SYMBIAN
  3466. +#include <private/qeventdispatcher_symbian_p.h>
  3467.  #else
  3468. -#  if !defined(QT_NO_GLIB)
  3469. -#    include "../kernel/qeventdispatcher_glib_p.h"
  3470. -#  endif
  3471. -#  include <private/qeventdispatcher_unix_p.h>
  3472. +#include <private/qeventdispatcher_unix_p.h>
  3473.  #endif
  3474.  
  3475.  #include "qthreadstorage.h"
  3476. @@ -83,9 +83,7 @@
  3477.  #   define old_qDebug qDebug
  3478.  #   undef qDebug
  3479.  # endif
  3480. -#if !defined(Q_OS_IOS)
  3481.  # include <CoreServices/CoreServices.h>
  3482. -#endif // !defined(Q_OS_IOS)
  3483.  
  3484.  # ifdef old_qDebug
  3485.  #   undef qDebug
  3486. @@ -94,37 +92,10 @@
  3487.  # endif
  3488.  #endif
  3489.  
  3490. -#if defined(Q_OS_LINUX) && !defined(QT_LINUXBASE)
  3491. -#include <sys/prctl.h>
  3492. -#endif
  3493. -
  3494. -#if defined(Q_OS_LINUX) && !defined(SCHED_IDLE)
  3495. -// from linux/sched.h
  3496. -# define SCHED_IDLE    5
  3497. -#endif
  3498. -
  3499. -#if defined(Q_OS_DARWIN) || !defined(Q_OS_OPENBSD) && defined(_POSIX_THREAD_PRIORITY_SCHEDULING) && (_POSIX_THREAD_PRIORITY_SCHEDULING-0 >= 0)
  3500. -#define QT_HAS_THREAD_PRIORITY_SCHEDULING
  3501. -#endif
  3502. -
  3503. -
  3504.  QT_BEGIN_NAMESPACE
  3505.  
  3506.  #ifndef QT_NO_THREAD
  3507.  
  3508. -enum { ThreadPriorityResetFlag = 0x80000000 };
  3509. -
  3510. -#if defined(Q_OS_LINUX) && defined(__GLIBC__) && (defined(Q_CC_GNU) || defined(Q_CC_INTEL))
  3511. -#define HAVE_TLS
  3512. -#endif
  3513. -#if defined(Q_CC_XLC) || defined (Q_CC_SUN)
  3514. -#define HAVE_TLS
  3515. -#endif
  3516. -
  3517. -#ifdef HAVE_TLS
  3518. -static __thread QThreadData *currentThreadData = 0;
  3519. -#endif
  3520. -
  3521.  static pthread_once_t current_thread_data_once = PTHREAD_ONCE_INIT;
  3522.  static pthread_key_t current_thread_data_key;
  3523.  
  3524. @@ -141,16 +112,7 @@
  3525.      // this destructor function, so we need to set it back to the
  3526.      // right value...
  3527.      pthread_setspecific(current_thread_data_key, p);
  3528. -    QThreadData *data = static_cast<QThreadData *>(p);
  3529. -    if (data->isAdopted) {
  3530. -        QThread *thread = data->thread;
  3531. -        Q_ASSERT(thread);
  3532. -        QThreadPrivate *thread_p = static_cast<QThreadPrivate *>(QObjectPrivate::get(thread));
  3533. -        Q_ASSERT(!thread_p->finished);
  3534. -        thread_p->finish(thread);
  3535. -    }
  3536. -    data->deref();
  3537. -
  3538. +    reinterpret_cast<QThreadData *>(p)->deref();
  3539.      // ... but we must reset it to zero before returning so we aren't
  3540.      // called again (POSIX allows implementations to call destructor
  3541.      // functions repeatedly until all values are zero)
  3542. @@ -167,69 +129,34 @@
  3543.      pthread_key_create(&current_thread_data_key, destroy_current_thread_data);
  3544.  }
  3545.  
  3546. -static void destroy_current_thread_data_key()
  3547. -{
  3548. -    pthread_once(&current_thread_data_once, create_current_thread_data_key);
  3549. -    pthread_key_delete(current_thread_data_key);
  3550. -}
  3551. -Q_DESTRUCTOR_FUNCTION(destroy_current_thread_data_key)
  3552. -
  3553. -
  3554. -// Utility functions for getting, setting and clearing thread specific data.
  3555. -static QThreadData *get_thread_data()
  3556. -{
  3557. -#ifdef HAVE_TLS
  3558. -    return currentThreadData;
  3559. -#else
  3560. -    pthread_once(&current_thread_data_once, create_current_thread_data_key);
  3561. -    return reinterpret_cast<QThreadData *>(pthread_getspecific(current_thread_data_key));
  3562. -#endif
  3563. -}
  3564. -
  3565. -static void set_thread_data(QThreadData *data)
  3566. +QThreadData *QThreadData::current()
  3567.  {
  3568. -#ifdef HAVE_TLS
  3569. -    currentThreadData = data;
  3570. -#endif
  3571.      pthread_once(&current_thread_data_once, create_current_thread_data_key);
  3572. -    pthread_setspecific(current_thread_data_key, data);
  3573. -}
  3574. -
  3575. -static void clear_thread_data()
  3576. -{
  3577. -#ifdef HAVE_TLS
  3578. -    currentThreadData = 0;
  3579. -#endif
  3580. -    pthread_setspecific(current_thread_data_key, 0);
  3581. -}
  3582.  
  3583. -QThreadData *QThreadData::current()
  3584. -{
  3585. -    QThreadData *data = get_thread_data();
  3586. +    QThreadData *data = reinterpret_cast<QThreadData *>(pthread_getspecific(current_thread_data_key));
  3587.      if (!data) {
  3588.          void *a;
  3589.          if (QInternal::activateCallbacks(QInternal::AdoptCurrentThread, &a)) {
  3590.              QThread *adopted = static_cast<QThread*>(a);
  3591.              Q_ASSERT(adopted);
  3592.              data = QThreadData::get2(adopted);
  3593. -            set_thread_data(data);
  3594. +            pthread_setspecific(current_thread_data_key, data);
  3595.              adopted->d_func()->running = true;
  3596.              adopted->d_func()->finished = false;
  3597.              static_cast<QAdoptedThread *>(adopted)->init();
  3598.          } else {
  3599.              data = new QThreadData;
  3600. +            pthread_setspecific(current_thread_data_key, data);
  3601.              QT_TRY {
  3602. -                set_thread_data(data);
  3603.                  data->thread = new QAdoptedThread(data);
  3604.              } QT_CATCH(...) {
  3605. -                clear_thread_data();
  3606. +                pthread_setspecific(current_thread_data_key, 0);
  3607.                  data->deref();
  3608.                  data = 0;
  3609.                  QT_RETHROW;
  3610.              }
  3611.              data->deref();
  3612.          }
  3613. -        data->isAdopted = true;
  3614.          data->threadId = (Qt::HANDLE)pthread_self();
  3615.          if (!QCoreApplicationPrivate::theMainThread)
  3616.              QCoreApplicationPrivate::theMainThread = data->thread;
  3617. @@ -242,6 +169,11 @@
  3618.  {
  3619.      Q_D(QThread);
  3620.      d->thread_id = pthread_self();
  3621. +#ifdef Q_OS_SYMBIAN
  3622. +    d->data->symbian_thread_handle = RThread();
  3623. +    TThreadId threadId = d->data->symbian_thread_handle.Id();
  3624. +    d->data->symbian_thread_handle.Open(threadId);
  3625. +#endif
  3626.  }
  3627.  
  3628.  /*
  3629. @@ -262,9 +194,6 @@
  3630.  
  3631.  void QThreadPrivate::createEventDispatcher(QThreadData *data)
  3632.  {
  3633. -#if defined(Q_OS_BLACKBERRY)
  3634. -    data->eventDispatcher = new QEventDispatcherBlackberry;
  3635. -#else
  3636.  #if !defined(QT_NO_GLIB)
  3637.      if (qgetenv("QT_NO_GLIB").isEmpty()
  3638.          && qgetenv("QT_NO_THREADED_GLIB").isEmpty()
  3639. @@ -272,111 +201,104 @@
  3640.          data->eventDispatcher = new QEventDispatcherGlib;
  3641.      else
  3642.  #endif
  3643. +#ifdef Q_OS_SYMBIAN
  3644. +        data->eventDispatcher = new QEventDispatcherSymbian;
  3645. +#else
  3646.      data->eventDispatcher = new QEventDispatcherUNIX;
  3647.  #endif
  3648. -
  3649.      data->eventDispatcher->startingUp();
  3650.  }
  3651.  
  3652.  #ifndef QT_NO_THREAD
  3653.  
  3654. -#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))
  3655. -static void setCurrentThreadName(pthread_t threadId, const char *name)
  3656. -{
  3657. -#  if defined(Q_OS_LINUX) && !defined(QT_LINUXBASE)
  3658. -    Q_UNUSED(threadId);
  3659. -    prctl(PR_SET_NAME, (unsigned long)name, 0, 0, 0);
  3660. -#  elif (defined(Q_OS_MAC) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6)
  3661. -    Q_UNUSED(threadId);
  3662. -    if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_6)
  3663. -        pthread_setname_np(name);
  3664. -#  elif defined(Q_OS_QNX)
  3665. -    pthread_setname_np(threadId, name);
  3666. -#  endif
  3667. -}
  3668. -#endif
  3669. -
  3670.  void *QThreadPrivate::start(void *arg)
  3671.  {
  3672. +    // Symbian Open C supports neither thread cancellation nor cleanup_push.
  3673. +#ifndef Q_OS_SYMBIAN
  3674.      pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
  3675.      pthread_cleanup_push(QThreadPrivate::finish, arg);
  3676. +#endif
  3677.  
  3678.      QThread *thr = reinterpret_cast<QThread *>(arg);
  3679.      QThreadData *data = QThreadData::get2(thr);
  3680. +    data->threadId = (Qt::HANDLE)pthread_self();
  3681.  
  3682. -    // do we need to reset the thread priority?
  3683. -    if (int(thr->d_func()->priority) & ThreadPriorityResetFlag) {
  3684. -        thr->setPriority(QThread::Priority(thr->d_func()->priority & ~ThreadPriorityResetFlag));
  3685. -    }
  3686. +#ifdef Q_OS_SYMBIAN
  3687. +    // Because Symbian Open C does not provide a way to convert between
  3688. +    // RThread and pthread_t, we must delay initialization of the RThread
  3689. +    // handle when creating a thread, until we are running in the new thread.
  3690. +    // Here, we pick up the current thread and assign that to the handle.
  3691. +    data->symbian_thread_handle = RThread();
  3692. +    TThreadId threadId = data->symbian_thread_handle.Id();
  3693. +    data->symbian_thread_handle.Open(threadId);
  3694. +#endif
  3695.  
  3696. -    data->threadId = (Qt::HANDLE)pthread_self();
  3697. -    set_thread_data(data);
  3698. +    pthread_once(&current_thread_data_once, create_current_thread_data_key);
  3699. +    pthread_setspecific(current_thread_data_key, data);
  3700.  
  3701.      data->ref();
  3702. -    {
  3703. -        QMutexLocker locker(&thr->d_func()->mutex);
  3704. -        data->quitNow = thr->d_func()->exited;
  3705. -    }
  3706. +    data->quitNow = false;
  3707.  
  3708.      // ### TODO: allow the user to create a custom event dispatcher
  3709.      createEventDispatcher(data);
  3710.  
  3711. -#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))
  3712. -    // sets the name of the current thread.
  3713. -    QString objectName = thr->objectName();
  3714. -
  3715. -    if (Q_LIKELY(objectName.isEmpty()))
  3716. -        setCurrentThreadName(thr->d_func()->thread_id, thr->metaObject()->className());
  3717. -    else
  3718. -        setCurrentThreadName(thr->d_func()->thread_id, objectName.toLocal8Bit());
  3719. -
  3720. -#endif
  3721. -
  3722.      emit thr->started();
  3723. +#ifndef Q_OS_SYMBIAN
  3724.      pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
  3725.      pthread_testcancel();
  3726. +#endif
  3727.      thr->run();
  3728.  
  3729. +#ifdef Q_OS_SYMBIAN
  3730. +    QThreadPrivate::finish(arg);
  3731. +#else
  3732.      pthread_cleanup_pop(1);
  3733. +#endif
  3734.  
  3735.      return 0;
  3736.  }
  3737.  
  3738. +#ifdef Q_OS_SYMBIAN
  3739. +void QThreadPrivate::finish(void *arg, bool lockAnyway, bool closeNativeHandle)
  3740. +#else
  3741.  void QThreadPrivate::finish(void *arg)
  3742. +#endif
  3743.  {
  3744.      QThread *thr = reinterpret_cast<QThread *>(arg);
  3745.      QThreadPrivate *d = thr->d_func();
  3746. +#ifdef Q_OS_SYMBIAN
  3747. +    if (lockAnyway)
  3748. +#endif
  3749. +        d->mutex.lock();
  3750.  
  3751. -    QMutexLocker locker(&d->mutex);
  3752. -
  3753. -    d->isInFinish = true;
  3754.      d->priority = QThread::InheritPriority;
  3755. -    bool terminated = d->terminated;
  3756. -    void *data = &d->data->tls;
  3757. -    locker.unlock();
  3758. -    if (terminated)
  3759. +    d->running = false;
  3760. +    d->finished = true;
  3761. +    if (d->terminated)
  3762.          emit thr->terminated();
  3763. -    emit thr->finished();
  3764. -    QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
  3765. -    QThreadStorageData::finish((void **)data);
  3766. -    locker.relock();
  3767.      d->terminated = false;
  3768. +    emit thr->finished();
  3769.  
  3770. +    if (d->data->eventDispatcher) {
  3771. +        d->data->eventDispatcher->closingDown();
  3772.      QAbstractEventDispatcher *eventDispatcher = d->data->eventDispatcher;
  3773. -    if (eventDispatcher) {
  3774.          d->data->eventDispatcher = 0;
  3775. -        locker.unlock();
  3776. -        eventDispatcher->closingDown();
  3777.          delete eventDispatcher;
  3778. -        locker.relock();
  3779.      }
  3780.  
  3781. -    d->thread_id = 0;
  3782. -    d->running = false;
  3783. -    d->finished = true;
  3784. +    void *data = &d->data->tls;
  3785. +    QThreadStorageData::finish((void **)data);
  3786.  
  3787. -    d->isInFinish = false;
  3788. +    d->thread_id = 0;
  3789. +#ifdef Q_OS_SYMBIAN
  3790. +    if (closeNativeHandle)
  3791. +        d->data->symbian_thread_handle.Close();
  3792. +#endif
  3793.      d->thread_done.wakeAll();
  3794. +#ifdef Q_OS_SYMBIAN
  3795. +    if (lockAnyway)
  3796. +#endif
  3797. +        d->mutex.unlock();
  3798.  }
  3799.  
  3800.  
  3801. @@ -401,7 +323,7 @@
  3802.  {
  3803.      int cores = -1;
  3804.  
  3805. -#if defined(Q_OS_MAC) && !defined(Q_WS_QPA)
  3806. +#if defined(Q_OS_MAC)
  3807.      // Mac OS X
  3808.      cores = MPProcessorsScheduled();
  3809.  #elif defined(Q_OS_HPUX)
  3810. @@ -429,6 +351,9 @@
  3811.  #elif defined(Q_OS_INTEGRITY)
  3812.      // as of aug 2008 Integrity only supports one single core CPU
  3813.      cores = 1;
  3814. +#elif defined(Q_OS_SYMBIAN)
  3815. +    // ### TODO - Get the number of cores from HAL? when multicore architectures (SMP) are supported
  3816. +    cores = 1;
  3817.  #elif defined(Q_OS_VXWORKS)
  3818.      // VxWorks
  3819.  #  if defined(QT_VXWORKS_HAS_CPUSET)
  3820. @@ -513,60 +438,16 @@
  3821.      thread_sleep(&ti);
  3822.  }
  3823.  
  3824. -#ifdef QT_HAS_THREAD_PRIORITY_SCHEDULING
  3825. -// Does some magic and calculate the Unix scheduler priorities
  3826. -// sched_policy is IN/OUT: it must be set to a valid policy before calling this function
  3827. -// sched_priority is OUT only
  3828. -static bool calculateUnixPriority(int priority, int *sched_policy, int *sched_priority)
  3829. -{
  3830. -#ifdef Q_OS_QNX
  3831. -    // without Round Robin drawn intensive apps will hog the cpu
  3832. -    // and make the system appear frozen
  3833. -   *sched_policy = SCHED_RR;
  3834. -#endif
  3835. -#ifdef SCHED_IDLE
  3836. -    if (priority == QThread::IdlePriority) {
  3837. -        *sched_policy = SCHED_IDLE;
  3838. -        *sched_priority = 0;
  3839. -        return true;
  3840. -    }
  3841. -    const int lowestPriority = QThread::LowestPriority;
  3842. -#else
  3843. -    const int lowestPriority = QThread::IdlePriority;
  3844. -#endif
  3845. -    const int highestPriority = QThread::TimeCriticalPriority;
  3846. -
  3847. -    int prio_min = sched_get_priority_min(*sched_policy);
  3848. -    int prio_max = sched_get_priority_max(*sched_policy);
  3849. -    if (prio_min == -1 || prio_max == -1)
  3850. -        return false;
  3851. -
  3852. -    int prio;
  3853. -    // crudely scale our priority enum values to the prio_min/prio_max
  3854. -    prio = ((priority - lowestPriority) * (prio_max - prio_min) / highestPriority) + prio_min;
  3855. -    prio = qMax(prio_min, qMin(prio_max, prio));
  3856. -
  3857. -    *sched_priority = prio;
  3858. -    return true;
  3859. -}
  3860. -#endif
  3861. -
  3862.  void QThread::start(Priority priority)
  3863.  {
  3864.      Q_D(QThread);
  3865.      QMutexLocker locker(&d->mutex);
  3866. -
  3867. -    if (d->isInFinish)
  3868. -        d->thread_done.wait(locker.mutex());
  3869. -
  3870.      if (d->running)
  3871.          return;
  3872.  
  3873.      d->running = true;
  3874.      d->finished = false;
  3875.      d->terminated = false;
  3876. -    d->returnCode = 0;
  3877. -    d->exited = false;
  3878.  
  3879.      pthread_attr_t attr;
  3880.      pthread_attr_init(&attr);
  3881. @@ -574,7 +455,8 @@
  3882.  
  3883.      d->priority = priority;
  3884.  
  3885. -#if defined(QT_HAS_THREAD_PRIORITY_SCHEDULING)
  3886. +#if defined(Q_OS_DARWIN) || !defined(Q_OS_OPENBSD) && !defined(Q_OS_SYMBIAN) && defined(_POSIX_THREAD_PRIORITY_SCHEDULING) && (_POSIX_THREAD_PRIORITY_SCHEDULING-0 >= 0)
  3887. +// ### Need to implement thread sheduling and priorities for symbian os. Implementation removed for now
  3888.      switch (priority) {
  3889.      case InheritPriority:
  3890.          {
  3891. @@ -592,14 +474,32 @@
  3892.                  break;
  3893.              }
  3894.  
  3895. -            int prio;
  3896. -            if (!calculateUnixPriority(priority, &sched_policy, &prio)) {
  3897. +            int prio_min = sched_get_priority_min(sched_policy);
  3898. +            int prio_max = sched_get_priority_max(sched_policy);
  3899. +            if (prio_min == -1 || prio_max == -1) {
  3900.                  // failed to get the scheduling parameters, don't
  3901.                  // bother setting the priority
  3902.                  qWarning("QThread::start: Cannot determine scheduler priority range");
  3903.                  break;
  3904.              }
  3905.  
  3906. +            int prio;
  3907. +            switch (priority) {
  3908. +            case IdlePriority:
  3909. +                prio = prio_min;
  3910. +                break;
  3911. +
  3912. +            case TimeCriticalPriority:
  3913. +                prio = prio_max;
  3914. +                break;
  3915. +
  3916. +            default:
  3917. +                // crudely scale our priority enum values to the prio_min/prio_max
  3918. +                prio = (priority * (prio_max - prio_min) / TimeCriticalPriority) + prio_min;
  3919. +                prio = qMax(prio_min, qMin(prio_max, prio));
  3920. +                break;
  3921. +            }
  3922. +
  3923.              sched_param sp;
  3924.              sp.sched_priority = prio;
  3925.  
  3926. @@ -607,15 +507,19 @@
  3927.                  || pthread_attr_setschedpolicy(&attr, sched_policy) != 0
  3928.                  || pthread_attr_setschedparam(&attr, &sp) != 0) {
  3929.                  // could not set scheduling hints, fallback to inheriting them
  3930. -                // we'll try again from inside the thread
  3931.                  pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
  3932. -                d->priority = Priority(priority | ThreadPriorityResetFlag);
  3933.              }
  3934.              break;
  3935.          }
  3936.      }
  3937. -#endif // QT_HAS_THREAD_PRIORITY_SCHEDULING
  3938. +#endif // _POSIX_THREAD_PRIORITY_SCHEDULING
  3939.  
  3940. +#ifdef Q_OS_SYMBIAN
  3941. +    if (d->stackSize == 0)
  3942. +        // The default stack size on Symbian is very small, making even basic
  3943. +        // operations like file I/O fail, so we increase it by default.
  3944. +        d->stackSize = 0x14000; // Maximum stack size on Symbian.
  3945. +#endif
  3946.  
  3947.      if (d->stackSize > 0) {
  3948.  #if defined(_POSIX_THREAD_ATTR_STACKSIZE) && (_POSIX_THREAD_ATTR_STACKSIZE-0 > 0)
  3949. @@ -641,7 +545,9 @@
  3950.      if (code == EPERM) {
  3951.          // caller does not have permission to set the scheduling
  3952.          // parameters/policy
  3953. +#ifndef Q_OS_SYMBIAN
  3954.          pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
  3955. +#endif
  3956.          code =
  3957.              pthread_create(&d->thread_id, &attr, QThreadPrivate::start, this);
  3958.      }
  3959. @@ -654,6 +560,9 @@
  3960.          d->running = false;
  3961.          d->finished = false;
  3962.          d->thread_id = 0;
  3963. +#ifdef Q_OS_SYMBIAN
  3964. +        d->data->symbian_thread_handle.Close();
  3965. +#endif
  3966.      }
  3967.  }
  3968.  
  3969. @@ -665,6 +574,7 @@
  3970.      if (!d->thread_id)
  3971.          return;
  3972.  
  3973. +#ifndef Q_OS_SYMBIAN
  3974.      int code = pthread_cancel(d->thread_id);
  3975.      if (code) {
  3976.          qWarning("QThread::start: Thread termination error: %s",
  3977. @@ -672,6 +582,26 @@
  3978.      } else {
  3979.          d->terminated = true;
  3980.      }
  3981. +#else
  3982. +    if (!d->running)
  3983. +        return;
  3984. +    if (!d->terminationEnabled) {
  3985. +        d->terminatePending = true;
  3986. +        return;
  3987. +    }
  3988. +
  3989. +    d->terminated = true;
  3990. +    // "false, false" meaning:
  3991. +    // 1. lockAnyway = false. Don't lock the mutex because it's already locked
  3992. +    //    (see above).
  3993. +    // 2. closeNativeSymbianHandle = false. We don't want to close the thread handle,
  3994. +    //    because we need it here to terminate the thread.
  3995. +    QThreadPrivate::finish(this, false, false);
  3996. +    d->data->symbian_thread_handle.Terminate(KErrNone);
  3997. +    d->data->symbian_thread_handle.Close();
  3998. +#endif
  3999. +
  4000. +
  4001.  }
  4002.  
  4003.  bool QThread::wait(unsigned long time)
  4004. @@ -699,11 +629,25 @@
  4005.      QThread *thr = currentThread();
  4006.      Q_ASSERT_X(thr != 0, "QThread::setTerminationEnabled()",
  4007.                 "Current thread was not started with QThread.");
  4008. -
  4009. +#ifndef Q_OS_SYMBIAN
  4010.      Q_UNUSED(thr)
  4011.      pthread_setcancelstate(enabled ? PTHREAD_CANCEL_ENABLE : PTHREAD_CANCEL_DISABLE, NULL);
  4012.      if (enabled)
  4013.          pthread_testcancel();
  4014. +#else
  4015. +    QThreadPrivate *d = thr->d_func();
  4016. +    QMutexLocker locker(&d->mutex);
  4017. +    d->terminationEnabled = enabled;
  4018. +    if (enabled && d->terminatePending) {
  4019. +        d->terminated = true;
  4020. +        // "false" meaning:
  4021. +        // -  lockAnyway = false. Don't lock the mutex because it's already locked
  4022. +        //    (see above).
  4023. +        QThreadPrivate::finish(thr, false);
  4024. +        locker.unlock(); // don't leave the mutex locked!
  4025. +        pthread_exit(NULL);
  4026. +    }
  4027. +#endif
  4028.  }
  4029.  
  4030.  void QThread::setPriority(Priority priority)
  4031. @@ -719,7 +663,7 @@
  4032.  
  4033.      // copied from start() with a few modifications:
  4034.  
  4035. -#ifdef QT_HAS_THREAD_PRIORITY_SCHEDULING
  4036. +#if defined(Q_OS_DARWIN) || !defined(Q_OS_OPENBSD) && defined(_POSIX_THREAD_PRIORITY_SCHEDULING) && (_POSIX_THREAD_PRIORITY_SCHEDULING-0 >= 0)
  4037.      int sched_policy;
  4038.      sched_param param;
  4039.  
  4040. @@ -730,28 +674,38 @@
  4041.          return;
  4042.      }
  4043.  
  4044. -    int prio;
  4045. -    if (!calculateUnixPriority(priority, &sched_policy, &prio)) {
  4046. +    int prio_min = sched_get_priority_min(sched_policy);
  4047. +    int prio_max = sched_get_priority_max(sched_policy);
  4048. +    if (prio_min == -1 || prio_max == -1) {
  4049.          // failed to get the scheduling parameters, don't
  4050.          // bother setting the priority
  4051.          qWarning("QThread::setPriority: Cannot determine scheduler priority range");
  4052.          return;
  4053.      }
  4054.  
  4055. -    param.sched_priority = prio;
  4056. -    int status = pthread_setschedparam(d->thread_id, sched_policy, &param);
  4057. +    int prio;
  4058. +    switch (priority) {
  4059. +    case InheritPriority:
  4060. +        qWarning("QThread::setPriority: Argument cannot be InheritPriority");
  4061. +        return;
  4062.  
  4063. -# ifdef SCHED_IDLE
  4064. -    // were we trying to set to idle priority and failed?
  4065. -    if (status == -1 && sched_policy == SCHED_IDLE && errno == EINVAL) {
  4066. -        // reset to lowest priority possible
  4067. -        pthread_getschedparam(d->thread_id, &sched_policy, &param);
  4068. -        param.sched_priority = sched_get_priority_min(sched_policy);
  4069. -        pthread_setschedparam(d->thread_id, sched_policy, &param);
  4070. +    case IdlePriority:
  4071. +        prio = prio_min;
  4072. +        break;
  4073. +
  4074. +    case TimeCriticalPriority:
  4075. +        prio = prio_max;
  4076. +        break;
  4077. +
  4078. +    default:
  4079. +        // crudely scale our priority enum values to the prio_min/prio_max
  4080. +        prio = (priority * (prio_max - prio_min) / TimeCriticalPriority) + prio_min;
  4081. +        prio = qMax(prio_min, qMin(prio_max, prio));
  4082. +        break;
  4083.      }
  4084. -# else
  4085. -    Q_UNUSED(status);
  4086. -# endif // SCHED_IDLE
  4087. +
  4088. +    param.sched_priority = prio;
  4089. +    pthread_setschedparam(d->thread_id, sched_policy, &param);
  4090.  #endif
  4091.  }
  4092.  
  4093. 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
  4094. --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qthread_win.cpp 2012-11-23 14:09:55.000000000 +0400
  4095. +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qthread_win.cpp 2011-06-23 11:45:00.000000000 +0400
  4096. @@ -1,18 +1,17 @@
  4097.  /****************************************************************************
  4098.  **
  4099. -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
  4100. -** Contact: http://www.qt-project.org/legal
  4101. +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
  4102. +** All rights reserved.
  4103. +** Contact: Nokia Corporation (qt-info@nokia.com)
  4104.  **
  4105.  ** This file is part of the QtCore module of the Qt Toolkit.
  4106.  **
  4107.  ** $QT_BEGIN_LICENSE:LGPL$
  4108. -** Commercial License Usage
  4109. -** Licensees holding valid commercial Qt licenses may use this file in
  4110. -** accordance with the commercial license agreement provided with the
  4111. +** Commercial Usage
  4112. +** Licensees holding valid Qt Commercial licenses may use this file in
  4113. +** accordance with the Qt Commercial License Agreement provided with the
  4114.  ** Software or, alternatively, in accordance with the terms contained in
  4115. -** a written agreement between you and Digia.  For licensing terms and
  4116. -** conditions see http://qt.digia.com/licensing.  For further information
  4117. -** use the contact form at http://qt.digia.com/contact-us.
  4118. +** a written agreement between you and Nokia.
  4119.  **
  4120.  ** GNU Lesser General Public License Usage
  4121.  ** Alternatively, this file may be used under the terms of the GNU Lesser
  4122. @@ -22,8 +21,8 @@
  4123.  ** ensure the GNU Lesser General Public License version 2.1 requirements
  4124.  ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  4125.  **
  4126. -** In addition, as a special exception, Digia gives you certain additional
  4127. -** rights.  These rights are described in the Digia Qt LGPL Exception
  4128. +** In addition, as a special exception, Nokia gives you certain additional
  4129. +** rights.  These rights are described in the Nokia Qt LGPL Exception
  4130.  ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  4131.  **
  4132.  ** GNU General Public License Usage
  4133. @@ -34,7 +33,8 @@
  4134.  ** ensure the GNU General Public License version 3.0 requirements will be
  4135.  ** met: http://www.gnu.org/copyleft/gpl.html.
  4136.  **
  4137. -**
  4138. +** If you have questions regarding the use of this file, please contact
  4139. +** Nokia at qt-info@nokia.com.
  4140.  ** $QT_END_LICENSE$
  4141.  **
  4142.  ****************************************************************************/
  4143. @@ -72,7 +72,7 @@
  4144.  QT_BEGIN_NAMESPACE
  4145.  
  4146.  void qt_watch_adopted_thread(const HANDLE adoptedThreadHandle, QThread *qthread);
  4147. -DWORD WINAPI qt_adopted_thread_watcher_function(LPVOID);
  4148. +void qt_adopted_thread_watcher_function(void *);
  4149.  
  4150.  static DWORD qt_current_thread_data_tls_index = TLS_OUT_OF_INDEXES;
  4151.  void qt_create_tls()
  4152. @@ -124,8 +124,6 @@
  4153.              }
  4154.              threadData->deref();
  4155.          }
  4156. -        threadData->isAdopted = true;
  4157. -        threadData->threadId = (Qt::HANDLE)GetCurrentThreadId();
  4158.  
  4159.          if (!QCoreApplicationPrivate::theMainThread) {
  4160.              QCoreApplicationPrivate::theMainThread = threadData->thread;
  4161. @@ -157,7 +155,7 @@
  4162.  static QVector<HANDLE> qt_adopted_thread_handles;
  4163.  static QVector<QThread *> qt_adopted_qthreads;
  4164.  static QMutex qt_adopted_thread_watcher_mutex;
  4165. -static DWORD qt_adopted_thread_watcher_id = 0;
  4166. +static HANDLE qt_adopted_thread_watcher_handle = 0;
  4167.  static HANDLE qt_adopted_thread_wakeup = 0;
  4168.  
  4169.  /*! \internal
  4170. @@ -168,25 +166,18 @@
  4171.  void qt_watch_adopted_thread(const HANDLE adoptedThreadHandle, QThread *qthread)
  4172.  {
  4173.      QMutexLocker lock(&qt_adopted_thread_watcher_mutex);
  4174. -
  4175. -    if (GetCurrentThreadId() == qt_adopted_thread_watcher_id) {
  4176. -#if !defined(Q_OS_WINCE) || (defined(_WIN32_WCE) && (_WIN32_WCE>=0x600))
  4177. -        CloseHandle(adoptedThreadHandle);
  4178. -#endif
  4179. -        return;
  4180. -    }
  4181. -
  4182.      qt_adopted_thread_handles.append(adoptedThreadHandle);
  4183.      qt_adopted_qthreads.append(qthread);
  4184.  
  4185.      // Start watcher thread if it is not already running.
  4186. -    if (qt_adopted_thread_watcher_id == 0) {
  4187. +    if (qt_adopted_thread_watcher_handle == 0) {
  4188.          if (qt_adopted_thread_wakeup == 0) {
  4189.              qt_adopted_thread_wakeup = CreateEvent(0, false, false, 0);
  4190.              qt_adopted_thread_handles.prepend(qt_adopted_thread_wakeup);
  4191.          }
  4192.  
  4193. -        CreateThread(0, 0, qt_adopted_thread_watcher_function, 0, 0, &qt_adopted_thread_watcher_id);
  4194. +        qt_adopted_thread_watcher_handle =
  4195. +            (HANDLE)_beginthread(qt_adopted_thread_watcher_function, 0, NULL);
  4196.      } else {
  4197.          SetEvent(qt_adopted_thread_wakeup);
  4198.      }
  4199. @@ -197,13 +188,13 @@
  4200.      When this happens it derefs the QThreadData for the adopted thread
  4201.      to make sure it gets cleaned up properly.
  4202.  */
  4203. -DWORD WINAPI qt_adopted_thread_watcher_function(LPVOID)
  4204. +void qt_adopted_thread_watcher_function(void *)
  4205.  {
  4206.      forever {
  4207.          qt_adopted_thread_watcher_mutex.lock();
  4208.  
  4209.          if (qt_adopted_thread_handles.count() == 1) {
  4210. -            qt_adopted_thread_watcher_id = 0;
  4211. +            qt_adopted_thread_watcher_handle = 0;
  4212.              qt_adopted_thread_watcher_mutex.unlock();
  4213.              break;
  4214.          }
  4215. @@ -228,7 +219,7 @@
  4216.              } while (ret == WAIT_TIMEOUT);
  4217.          }
  4218.  
  4219. -        if (ret == WAIT_FAILED || ret >= WAIT_OBJECT_0 + uint(count)) {
  4220. +        if (ret == WAIT_FAILED || !(ret >= WAIT_OBJECT_0 && ret < WAIT_OBJECT_0 + uint(count))) {
  4221.              qWarning("QThread internal error while waiting for adopted threads: %d", int(GetLastError()));
  4222.              continue;
  4223.          }
  4224. @@ -240,33 +231,15 @@
  4225.          } else {
  4226.  //             printf("(qt) - qt_adopted_thread_watcher_function... called\n");
  4227.              const int qthreadIndex = handleIndex - 1;
  4228. -
  4229. -            qt_adopted_thread_watcher_mutex.lock();
  4230. -            QThreadData *data = QThreadData::get2(qt_adopted_qthreads.at(qthreadIndex));
  4231. -            qt_adopted_thread_watcher_mutex.unlock();
  4232. -            if (data->isAdopted) {
  4233. -                QThread *thread = data->thread;
  4234. -                Q_ASSERT(thread);
  4235. -                QThreadPrivate *thread_p = static_cast<QThreadPrivate *>(QObjectPrivate::get(thread));
  4236. -                Q_ASSERT(!thread_p->finished);
  4237. -                thread_p->finish(thread);
  4238. -            }
  4239. -            data->deref();
  4240. -
  4241. -            QMutexLocker lock(&qt_adopted_thread_watcher_mutex);
  4242. +            QThreadData::get2(qt_adopted_qthreads.at(qthreadIndex))->deref();
  4243.  #if !defined(Q_OS_WINCE) || (defined(_WIN32_WCE) && (_WIN32_WCE>=0x600))
  4244.              CloseHandle(qt_adopted_thread_handles.at(handleIndex));
  4245.  #endif
  4246. +            QMutexLocker lock(&qt_adopted_thread_watcher_mutex);
  4247.              qt_adopted_thread_handles.remove(handleIndex);
  4248.              qt_adopted_qthreads.remove(qthreadIndex);
  4249.          }
  4250.      }
  4251. -
  4252. -    QThreadData *threadData = reinterpret_cast<QThreadData *>(TlsGetValue(qt_current_thread_data_tls_index));
  4253. -    if (threadData)
  4254. -        threadData->deref();
  4255. -
  4256. -    return 0;
  4257.  }
  4258.  
  4259.  #if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINCE)
  4260. @@ -315,21 +288,17 @@
  4261.  
  4262.  #ifndef QT_NO_THREAD
  4263.  
  4264. -unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(void *arg)
  4265. +unsigned int __stdcall QThreadPrivate::start(void *arg)
  4266.  {
  4267.      QThread *thr = reinterpret_cast<QThread *>(arg);
  4268.      QThreadData *data = QThreadData::get2(thr);
  4269.  
  4270.      qt_create_tls();
  4271.      TlsSetValue(qt_current_thread_data_tls_index, data);
  4272. -    data->threadId = (Qt::HANDLE)GetCurrentThreadId();
  4273.  
  4274.      QThread::setTerminationEnabled(false);
  4275.  
  4276. -    {
  4277. -        QMutexLocker locker(&thr->d_func()->mutex);
  4278. -        data->quitNow = thr->d_func()->exited;
  4279. -    }
  4280. +    data->quitNow = false;
  4281.      // ### TODO: allow the user to create a custom event dispatcher
  4282.      createEventDispatcher(data);
  4283.  
  4284. @@ -354,33 +323,24 @@
  4285.      QThread *thr = reinterpret_cast<QThread *>(arg);
  4286.      QThreadPrivate *d = thr->d_func();
  4287.  
  4288. -    QMutexLocker locker(lockAnyway ? &d->mutex : 0);
  4289. -    d->isInFinish = true;
  4290. +    if (lockAnyway)
  4291. +        d->mutex.lock();
  4292.      d->priority = QThread::InheritPriority;
  4293. -    bool terminated = d->terminated;
  4294. -    void **tls_data = reinterpret_cast<void **>(&d->data->tls);
  4295. -    locker.unlock();
  4296. -    if (terminated)
  4297. +    d->running = false;
  4298. +    d->finished = true;
  4299. +    if (d->terminated)
  4300.          emit thr->terminated();
  4301. -    emit thr->finished();
  4302. -    QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
  4303. -    QThreadStorageData::finish(tls_data);
  4304. -    locker.relock();
  4305. -
  4306.      d->terminated = false;
  4307. +    emit thr->finished();
  4308.  
  4309. +    if (d->data->eventDispatcher) {
  4310. +        d->data->eventDispatcher->closingDown();
  4311.      QAbstractEventDispatcher *eventDispatcher = d->data->eventDispatcher;
  4312. -    if (eventDispatcher) {
  4313.          d->data->eventDispatcher = 0;
  4314. -        locker.unlock();
  4315. -        eventDispatcher->closingDown();
  4316.          delete eventDispatcher;
  4317. -        locker.relock();
  4318.      }
  4319.  
  4320. -    d->running = false;
  4321. -    d->finished = true;
  4322. -    d->isInFinish = false;
  4323. +    QThreadStorageData::finish(reinterpret_cast<void **>(&d->data->tls));
  4324.  
  4325.      if (!d->waiters) {
  4326.          CloseHandle(d->handle);
  4327. @@ -389,6 +349,8 @@
  4328.  
  4329.      d->id = 0;
  4330.  
  4331. +    if (lockAnyway)
  4332. +        d->mutex.unlock();
  4333.  }
  4334.  
  4335.  /**************************************************************************
  4336. @@ -437,20 +399,12 @@
  4337.      Q_D(QThread);
  4338.      QMutexLocker locker(&d->mutex);
  4339.  
  4340. -    if (d->isInFinish) {
  4341. -        locker.unlock();
  4342. -        wait();
  4343. -        locker.relock();
  4344. -    }
  4345. -
  4346.      if (d->running)
  4347.          return;
  4348.  
  4349.      d->running = true;
  4350.      d->finished = false;
  4351.      d->terminated = false;
  4352. -    d->exited = false;
  4353. -    d->returnCode = 0;
  4354.  
  4355.      /*
  4356.        NOTE: we create the thread in the suspended state, set the
  4357. 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
  4358. --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qwaitcondition.h    2012-11-23 14:09:55.000000000 +0400
  4359. +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qwaitcondition.h    2011-06-23 11:45:00.000000000 +0400
  4360. @@ -1,18 +1,17 @@
  4361.  /****************************************************************************
  4362.  **
  4363. -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
  4364. -** Contact: http://www.qt-project.org/legal
  4365. +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
  4366. +** All rights reserved.
  4367. +** Contact: Nokia Corporation (qt-info@nokia.com)
  4368.  **
  4369.  ** This file is part of the QtCore module of the Qt Toolkit.
  4370.  **
  4371.  ** $QT_BEGIN_LICENSE:LGPL$
  4372. -** Commercial License Usage
  4373. -** Licensees holding valid commercial Qt licenses may use this file in
  4374. -** accordance with the commercial license agreement provided with the
  4375. +** Commercial Usage
  4376. +** Licensees holding valid Qt Commercial licenses may use this file in
  4377. +** accordance with the Qt Commercial License Agreement provided with the
  4378.  ** Software or, alternatively, in accordance with the terms contained in
  4379. -** a written agreement between you and Digia.  For licensing terms and
  4380. -** conditions see http://qt.digia.com/licensing.  For further information
  4381. -** use the contact form at http://qt.digia.com/contact-us.
  4382. +** a written agreement between you and Nokia.
  4383.  **
  4384.  ** GNU Lesser General Public License Usage
  4385.  ** Alternatively, this file may be used under the terms of the GNU Lesser
  4386. @@ -22,8 +21,8 @@
  4387.  ** ensure the GNU Lesser General Public License version 2.1 requirements
  4388.  ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  4389.  **
  4390. -** In addition, as a special exception, Digia gives you certain additional
  4391. -** rights.  These rights are described in the Digia Qt LGPL Exception
  4392. +** In addition, as a special exception, Nokia gives you certain additional
  4393. +** rights.  These rights are described in the Nokia Qt LGPL Exception
  4394.  ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  4395.  **
  4396.  ** GNU General Public License Usage
  4397. @@ -34,7 +33,8 @@
  4398.  ** ensure the GNU General Public License version 3.0 requirements will be
  4399.  ** met: http://www.gnu.org/copyleft/gpl.html.
  4400.  **
  4401. -**
  4402. +** If you have questions regarding the use of this file, please contact
  4403. +** Nokia at qt-info@nokia.com.
  4404.  ** $QT_END_LICENSE$
  4405.  **
  4406.  ****************************************************************************/
  4407. 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
  4408. --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qwaitcondition.qdoc 2012-11-23 14:09:55.000000000 +0400
  4409. +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qwaitcondition.qdoc 2011-06-23 11:45:00.000000000 +0400
  4410. @@ -1,26 +1,40 @@
  4411.  /****************************************************************************
  4412.  **
  4413. -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
  4414. -** Contact: http://www.qt-project.org/legal
  4415. +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
  4416. +** All rights reserved.
  4417. +** Contact: Nokia Corporation (qt-info@nokia.com)
  4418.  **
  4419.  ** This file is part of the documentation of the Qt Toolkit.
  4420.  **
  4421. -** $QT_BEGIN_LICENSE:FDL$
  4422. -** Commercial License Usage
  4423. -** Licensees holding valid commercial Qt licenses may use this file in
  4424. -** accordance with the commercial license agreement provided with the
  4425. +** $QT_BEGIN_LICENSE:LGPL$
  4426. +** Commercial Usage
  4427. +** Licensees holding valid Qt Commercial licenses may use this file in
  4428. +** accordance with the Qt Commercial License Agreement provided with the
  4429.  ** Software or, alternatively, in accordance with the terms contained in
  4430. -** a written agreement between you and Digia.  For licensing terms and
  4431. -** conditions see http://qt.digia.com/licensing.  For further information
  4432. -** use the contact form at http://qt.digia.com/contact-us.
  4433. -**
  4434. -** GNU Free Documentation License Usage
  4435. -** Alternatively, this file may be used under the terms of the GNU Free
  4436. -** Documentation License version 1.3 as published by the Free Software
  4437. -** Foundation and appearing in the file included in the packaging of
  4438. -** this file.  Please review the following information to ensure
  4439. -** the GNU Free Documentation License version 1.3 requirements
  4440. -** will be met: http://www.gnu.org/copyleft/fdl.html.
  4441. +** a written agreement between you and Nokia.
  4442. +**
  4443. +** GNU Lesser General Public License Usage
  4444. +** Alternatively, this file may be used under the terms of the GNU Lesser
  4445. +** General Public License version 2.1 as published by the Free Software
  4446. +** Foundation and appearing in the file LICENSE.LGPL included in the
  4447. +** packaging of this file.  Please review the following information to
  4448. +** ensure the GNU Lesser General Public License version 2.1 requirements
  4449. +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  4450. +**
  4451. +** In addition, as a special exception, Nokia gives you certain additional
  4452. +** rights.  These rights are described in the Nokia Qt LGPL Exception
  4453. +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  4454. +**
  4455. +** GNU General Public License Usage
  4456. +** Alternatively, this file may be used under the terms of the GNU
  4457. +** General Public License version 3.0 as published by the Free Software
  4458. +** Foundation and appearing in the file LICENSE.GPL included in the
  4459. +** packaging of this file.  Please review the following information to
  4460. +** ensure the GNU General Public License version 3.0 requirements will be
  4461. +** met: http://www.gnu.org/copyleft/gpl.html.
  4462. +**
  4463. +** If you have questions regarding the use of this file, please contact
  4464. +** Nokia at qt-info@nokia.com.
  4465.  ** $QT_END_LICENSE$
  4466.  **
  4467.  ****************************************************************************/
  4468. 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
  4469. --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qwaitcondition_symbian.cpp  2012-11-23 14:09:55.000000000 +0400
  4470. +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qwaitcondition_symbian.cpp  1970-01-01 03:00:00.000000000 +0300
  4471. @@ -1,199 +0,0 @@
  4472. -/****************************************************************************
  4473. -**
  4474. -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
  4475. -** Contact: http://www.qt-project.org/legal
  4476. -**
  4477. -** This file is part of the QtCore module of the Qt Toolkit.
  4478. -**
  4479. -** $QT_BEGIN_LICENSE:LGPL$
  4480. -** Commercial License Usage
  4481. -** Licensees holding valid commercial Qt licenses may use this file in
  4482. -** accordance with the commercial license agreement provided with the
  4483. -** Software or, alternatively, in accordance with the terms contained in
  4484. -** a written agreement between you and Digia.  For licensing terms and
  4485. -** conditions see http://qt.digia.com/licensing.  For further information
  4486. -** use the contact form at http://qt.digia.com/contact-us.
  4487. -**
  4488. -** GNU Lesser General Public License Usage
  4489. -** Alternatively, this file may be used under the terms of the GNU Lesser
  4490. -** General Public License version 2.1 as published by the Free Software
  4491. -** Foundation and appearing in the file LICENSE.LGPL included in the
  4492. -** packaging of this file.  Please review the following information to
  4493. -** ensure the GNU Lesser General Public License version 2.1 requirements
  4494. -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  4495. -**
  4496. -** In addition, as a special exception, Digia gives you certain additional
  4497. -** rights.  These rights are described in the Digia Qt LGPL Exception
  4498. -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  4499. -**
  4500. -** GNU General Public License Usage
  4501. -** Alternatively, this file may be used under the terms of the GNU
  4502. -** General Public License version 3.0 as published by the Free Software
  4503. -** Foundation and appearing in the file LICENSE.GPL included in the
  4504. -** packaging of this file.  Please review the following information to
  4505. -** ensure the GNU General Public License version 3.0 requirements will be
  4506. -** met: http://www.gnu.org/copyleft/gpl.html.
  4507. -**
  4508. -**
  4509. -** $QT_END_LICENSE$
  4510. -**
  4511. -****************************************************************************/
  4512. -
  4513. -#include "qplatformdefs.h"
  4514. -#include "qwaitcondition.h"
  4515. -#include "qmutex.h"
  4516. -#include "qreadwritelock.h"
  4517. -#include "qatomic.h"
  4518. -#include "qstring.h"
  4519. -#include "qelapsedtimer.h"
  4520. -
  4521. -#include "qmutex_p.h"
  4522. -#include "qreadwritelock_p.h"
  4523. -
  4524. -#ifndef QT_NO_THREAD
  4525. -
  4526. -QT_BEGIN_NAMESPACE
  4527. -
  4528. -static void report_error(int err, const char *where, const char *what)
  4529. -{
  4530. -    if (err != KErrNone)
  4531. -        qWarning("%s: %s failure: %d", where, what, err);
  4532. -}
  4533. -
  4534. -class QWaitConditionPrivate {
  4535. -public:
  4536. -    RMutex mutex;
  4537. -    RCondVar cond;
  4538. -    int waiters;
  4539. -    int wakeups;
  4540. -
  4541. -    QWaitConditionPrivate()
  4542. -    : waiters(0), wakeups(0)
  4543. -    {
  4544. -        qt_symbian_throwIfError(mutex.CreateLocal());
  4545. -        int err = cond.CreateLocal();
  4546. -        if (err != KErrNone) {
  4547. -            mutex.Close();
  4548. -            qt_symbian_throwIfError(err);
  4549. -        }
  4550. -    }
  4551. -
  4552. -    ~QWaitConditionPrivate()
  4553. -    {
  4554. -        cond.Close();
  4555. -        mutex.Close();
  4556. -    }
  4557. -
  4558. -    bool wait(unsigned long time)
  4559. -    {
  4560. -        TInt err = KErrNone;
  4561. -        if (time == ULONG_MAX) {
  4562. -            // untimed wait, loop because RCondVar::Wait may return before the condition is triggered
  4563. -            do {
  4564. -                err = cond.Wait(mutex);
  4565. -            } while (err == KErrNone && wakeups == 0);
  4566. -        } else {
  4567. -            unsigned long maxWait = KMaxTInt / 1000;
  4568. -            QElapsedTimer waitTimer;
  4569. -            do {
  4570. -                waitTimer.start();
  4571. -                unsigned long waitTime = qMin(maxWait, time);
  4572. -                // wait at least 1ms, as 0 means no wait
  4573. -                err = cond.TimedWait(mutex, qMax(1ul, waitTime) * 1000);
  4574. -                // RCondVar::TimedWait may return before the condition is triggered, update the timeout with actual wait time
  4575. -                time -= qMin((unsigned long)waitTimer.elapsed(), waitTime);
  4576. -            } while ((err == KErrNone && wakeups == 0) || (err == KErrTimedOut && time > 0));
  4577. -        }
  4578. -
  4579. -        Q_ASSERT_X(waiters > 0, "QWaitCondition::wait", "internal error (waiters)");
  4580. -        --waiters;
  4581. -        if (err == KErrNone) {
  4582. -            Q_ASSERT_X(wakeups > 0, "QWaitCondition::wait", "internal error (wakeups)");
  4583. -            --wakeups;
  4584. -        }
  4585. -
  4586. -        // if err is KErrGeneral it signals that the RCondVar is closed along with the mutex and that this has been deleted
  4587. -        // we must not access any member variables in this case
  4588. -        if (err != KErrGeneral)
  4589. -            mutex.Signal();
  4590. -
  4591. -        if (err && err != KErrTimedOut)
  4592. -            report_error(err, "QWaitCondition::wait()", "cv wait");
  4593. -        return err == KErrNone;
  4594. -    }
  4595. -};
  4596. -
  4597. -QWaitCondition::QWaitCondition()
  4598. -{
  4599. -    d = new QWaitConditionPrivate;
  4600. -}
  4601. -
  4602. -QWaitCondition::~QWaitCondition()
  4603. -{
  4604. -    delete d;
  4605. -}
  4606. -
  4607. -void QWaitCondition::wakeOne()
  4608. -{
  4609. -    d->mutex.Wait();
  4610. -    d->wakeups = qMin(d->wakeups + 1, d->waiters);
  4611. -    d->cond.Signal();
  4612. -    d->mutex.Signal();
  4613. -}
  4614. -
  4615. -void QWaitCondition::wakeAll()
  4616. -{
  4617. -    d->mutex.Wait();
  4618. -    d->wakeups = d->waiters;
  4619. -    d->cond.Broadcast();
  4620. -    d->mutex.Signal();
  4621. -}
  4622. -
  4623. -bool QWaitCondition::wait(QMutex *mutex, unsigned long time)
  4624. -{
  4625. -    if (! mutex)
  4626. -        return false;
  4627. -    if (mutex->d->recursive) {
  4628. -        qWarning("QWaitCondition: cannot wait on recursive mutexes");
  4629. -        return false;
  4630. -    }
  4631. -
  4632. -    d->mutex.Wait();
  4633. -    ++d->waiters;
  4634. -    mutex->unlock();
  4635. -
  4636. -    bool returnValue = d->wait(time);
  4637. -
  4638. -    mutex->lock();
  4639. -
  4640. -    return returnValue;
  4641. -}
  4642. -
  4643. -bool QWaitCondition::wait(QReadWriteLock *readWriteLock, unsigned long time)
  4644. -{
  4645. -    if (!readWriteLock || readWriteLock->d->accessCount == 0)
  4646. -        return false;
  4647. -    if (readWriteLock->d->accessCount < -1) {
  4648. -        qWarning("QWaitCondition: cannot wait on QReadWriteLocks with recursive lockForWrite()");
  4649. -        return false;
  4650. -    }
  4651. -
  4652. -    d->mutex.Wait();
  4653. -    ++d->waiters;
  4654. -
  4655. -    int previousAccessCount = readWriteLock->d->accessCount;
  4656. -    readWriteLock->unlock();
  4657. -
  4658. -    bool returnValue = d->wait(time);
  4659. -
  4660. -    if (previousAccessCount < 0)
  4661. -        readWriteLock->lockForWrite();
  4662. -    else
  4663. -        readWriteLock->lockForRead();
  4664. -
  4665. -    return returnValue;
  4666. -}
  4667. -
  4668. -QT_END_NAMESPACE
  4669. -
  4670. -#endif // QT_NO_THREAD
  4671. 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
  4672. --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qwaitcondition_unix.cpp 2012-11-23 14:09:55.000000000 +0400
  4673. +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qwaitcondition_unix.cpp 2011-06-23 11:45:00.000000000 +0400
  4674. @@ -1,18 +1,17 @@
  4675.  /****************************************************************************
  4676.  **
  4677. -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
  4678. -** Contact: http://www.qt-project.org/legal
  4679. +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
  4680. +** All rights reserved.
  4681. +** Contact: Nokia Corporation (qt-info@nokia.com)
  4682.  **
  4683.  ** This file is part of the QtCore module of the Qt Toolkit.
  4684.  **
  4685.  ** $QT_BEGIN_LICENSE:LGPL$
  4686. -** Commercial License Usage
  4687. -** Licensees holding valid commercial Qt licenses may use this file in
  4688. -** accordance with the commercial license agreement provided with the
  4689. +** Commercial Usage
  4690. +** Licensees holding valid Qt Commercial licenses may use this file in
  4691. +** accordance with the Qt Commercial License Agreement provided with the
  4692.  ** Software or, alternatively, in accordance with the terms contained in
  4693. -** a written agreement between you and Digia.  For licensing terms and
  4694. -** conditions see http://qt.digia.com/licensing.  For further information
  4695. -** use the contact form at http://qt.digia.com/contact-us.
  4696. +** a written agreement between you and Nokia.
  4697.  **
  4698.  ** GNU Lesser General Public License Usage
  4699.  ** Alternatively, this file may be used under the terms of the GNU Lesser
  4700. @@ -22,8 +21,8 @@
  4701.  ** ensure the GNU Lesser General Public License version 2.1 requirements
  4702.  ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  4703.  **
  4704. -** In addition, as a special exception, Digia gives you certain additional
  4705. -** rights.  These rights are described in the Digia Qt LGPL Exception
  4706. +** In addition, as a special exception, Nokia gives you certain additional
  4707. +** rights.  These rights are described in the Nokia Qt LGPL Exception
  4708.  ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  4709.  **
  4710.  ** GNU General Public License Usage
  4711. @@ -34,7 +33,8 @@
  4712.  ** ensure the GNU General Public License version 3.0 requirements will be
  4713.  ** met: http://www.gnu.org/copyleft/gpl.html.
  4714.  **
  4715. -**
  4716. +** If you have questions regarding the use of this file, please contact
  4717. +** Nokia at qt-info@nokia.com.
  4718.  ** $QT_END_LICENSE$
  4719.  **
  4720.  ****************************************************************************/
  4721. @@ -61,8 +61,9 @@
  4722.          qWarning("%s: %s failure: %s", where, what, qPrintable(qt_error_string(code)));
  4723.  }
  4724.  
  4725. -class QWaitConditionPrivate {
  4726. -public:
  4727. +
  4728. +
  4729. +struct QWaitConditionPrivate {
  4730.      pthread_mutex_t mutex;
  4731.      pthread_cond_t cond;
  4732.      int waiters;
  4733. 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
  4734. --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/qwaitcondition_win.cpp  2012-11-23 14:09:55.000000000 +0400
  4735. +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/qwaitcondition_win.cpp  2011-06-23 11:45:00.000000000 +0400
  4736. @@ -1,18 +1,17 @@
  4737.  /****************************************************************************
  4738.  **
  4739. -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
  4740. -** Contact: http://www.qt-project.org/legal
  4741. +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
  4742. +** All rights reserved.
  4743. +** Contact: Nokia Corporation (qt-info@nokia.com)
  4744.  **
  4745.  ** This file is part of the QtCore module of the Qt Toolkit.
  4746.  **
  4747.  ** $QT_BEGIN_LICENSE:LGPL$
  4748. -** Commercial License Usage
  4749. -** Licensees holding valid commercial Qt licenses may use this file in
  4750. -** accordance with the commercial license agreement provided with the
  4751. +** Commercial Usage
  4752. +** Licensees holding valid Qt Commercial licenses may use this file in
  4753. +** accordance with the Qt Commercial License Agreement provided with the
  4754.  ** Software or, alternatively, in accordance with the terms contained in
  4755. -** a written agreement between you and Digia.  For licensing terms and
  4756. -** conditions see http://qt.digia.com/licensing.  For further information
  4757. -** use the contact form at http://qt.digia.com/contact-us.
  4758. +** a written agreement between you and Nokia.
  4759.  **
  4760.  ** GNU Lesser General Public License Usage
  4761.  ** Alternatively, this file may be used under the terms of the GNU Lesser
  4762. @@ -22,8 +21,8 @@
  4763.  ** ensure the GNU Lesser General Public License version 2.1 requirements
  4764.  ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  4765.  **
  4766. -** In addition, as a special exception, Digia gives you certain additional
  4767. -** rights.  These rights are described in the Digia Qt LGPL Exception
  4768. +** In addition, as a special exception, Nokia gives you certain additional
  4769. +** rights.  These rights are described in the Nokia Qt LGPL Exception
  4770.  ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  4771.  **
  4772.  ** GNU General Public License Usage
  4773. @@ -34,7 +33,8 @@
  4774.  ** ensure the GNU General Public License version 3.0 requirements will be
  4775.  ** met: http://www.gnu.org/copyleft/gpl.html.
  4776.  **
  4777. -**
  4778. +** If you have questions regarding the use of this file, please contact
  4779. +** Nokia at qt-info@nokia.com.
  4780.  ** $QT_END_LICENSE$
  4781.  **
  4782.  ****************************************************************************/
  4783. 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
  4784. --- ./qt-everywhere-opensource-src-4.8.4/src/corelib/thread/thread.pri  2012-11-23 14:09:55.000000000 +0400
  4785. +++ ./qt-everywhere-opensource-src-4.8.4-patched/src/corelib/thread/thread.pri  2011-06-23 11:45:00.000000000 +0400
  4786. @@ -24,18 +24,10 @@
  4787.             thread/qthread.cpp \
  4788.             thread/qthreadstorage.cpp
  4789.  
  4790. -unix:!symbian:SOURCES += thread/qmutex_unix.cpp \
  4791. +unix:SOURCES += thread/qmutex_unix.cpp \
  4792.                           thread/qthread_unix.cpp \
  4793.                           thread/qwaitcondition_unix.cpp
  4794.  
  4795. -symbian:SOURCES += thread/qmutex_symbian.cpp \
  4796. -                   thread/qthread_symbian.cpp \
  4797. -                   thread/qwaitcondition_symbian.cpp
  4798. -
  4799.  win32:SOURCES += thread/qmutex_win.cpp \
  4800.                   thread/qthread_win.cpp \
  4801.          thread/qwaitcondition_win.cpp
  4802. -
  4803. -integrity:SOURCES += thread/qmutex_unix.cpp \
  4804. -                thread/qthread_unix.cpp \
  4805. -       thread/qwaitcondition_unix.cpp
Add Comment
Please, Sign In to add comment