diff options
author | Murray Read <ext-murray.2.read@nokia.com> | 2012-02-06 11:33:07 (GMT) |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-08 00:52:00 (GMT) |
commit | 4490850b9286d9b01fab9bc8900deb1598398f2e (patch) | |
tree | 24868d540c24316f2c1d91d0bc9f797236aa6817 /tests/auto/qthread/tst_qthread.cpp | |
parent | f343fc7c0844fc33886f3e25d49e043062c06e7a (diff) | |
download | Qt-4490850b9286d9b01fab9bc8900deb1598398f2e.zip Qt-4490850b9286d9b01fab9bc8900deb1598398f2e.tar.gz Qt-4490850b9286d9b01fab9bc8900deb1598398f2e.tar.bz2 |
Handling adopted thread death with active timers on Symbian
Timers are thread local objects on Symbian. When the adopted thread
monitor tries to tidy up a thread, any existing qt timers will be
cleaned up. But that has to be done very carefully without touching the
underlying symbian timer objects.
Checks are added to make sure the Symbian timers are only touched in
the correct thread.
Task-number: ou1cimx1#960478
Change-Id: If16750b455aa576aa9f2d93657a3627d18060272
Reviewed-by: Shane Kearns <ext-shane.2.kearns@nokia.com>
Diffstat (limited to 'tests/auto/qthread/tst_qthread.cpp')
-rw-r--r-- | tests/auto/qthread/tst_qthread.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/auto/qthread/tst_qthread.cpp b/tests/auto/qthread/tst_qthread.cpp index c1b2a95..4a8baa0 100644 --- a/tests/auto/qthread/tst_qthread.cpp +++ b/tests/auto/qthread/tst_qthread.cpp @@ -102,6 +102,7 @@ private slots: void adoptedThreadSetPriority(); void adoptedThreadExit(); void adoptedThreadExec(); + void adoptThreadExitWithActiveTimer(); void adoptedThreadFinished(); void adoptedThreadExecFinished(); void adoptMultipleThreads(); @@ -1010,6 +1011,32 @@ void tst_QThread::adoptMultipleThreadsOverlap() QVERIFY(!QTestEventLoop::instance().timeout()); QCOMPARE(int(recorder.activationCount), numThreads); } + +void adoptedThreadActiveTimerFunction(void *) +{ + QThread * const adoptedThread = QThread::currentThread(); + QEventLoop eventLoop(adoptedThread); + + const int code = 1; + Exit_Object o; + o.thread = adoptedThread; + o.code = code; + QTimer::singleShot(100, &o, SLOT(slot())); + + // create a timer that will still be active when the thread finishes + QTimer::singleShot(3000, &o, SLOT(slot())); + + const int result = eventLoop.exec(); + QCOMPARE(result, code); +} + +void tst_QThread::adoptThreadExitWithActiveTimer() +{ + NativeThreadWrapper nativeThread; + nativeThread.start(adoptedThreadActiveTimerFunction); + nativeThread.join(); +} + void tst_QThread::stressTest() { #if defined(Q_OS_WINCE) |