summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2010-09-22 12:18:44 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2010-09-22 12:26:27 (GMT)
commitb93947f5a25b3cc021518b944dc96b892f672bd3 (patch)
tree8307c61613e4357778b2ef891b573d6a69fe03c5 /tests
parent4035ec3e9ed5ef904dd6f22adaf5e9deb24e9455 (diff)
downloadQt-b93947f5a25b3cc021518b944dc96b892f672bd3.zip
Qt-b93947f5a25b3cc021518b944dc96b892f672bd3.tar.gz
Qt-b93947f5a25b3cc021518b944dc96b892f672bd3.tar.bz2
QThread: make sure start works even if called after exit
Regression in 4.7.0 introduced by 13ca61fcfdc53a6a06a Reviewed-by: brad Task-number: QTBUG-13810
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qthread/tst_qthread.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/qthread/tst_qthread.cpp b/tests/auto/qthread/tst_qthread.cpp
index 7a5b053..843749a 100644
--- a/tests/auto/qthread/tst_qthread.cpp
+++ b/tests/auto/qthread/tst_qthread.cpp
@@ -49,6 +49,7 @@
#include <qtimer.h>
#include <qwaitcondition.h>
#include <qdebug.h>
+#include <qmetaobject.h>
#ifdef Q_OS_UNIX
#include <pthread.h>
@@ -104,6 +105,8 @@ private slots:
void adoptedThreadFinished();
void adoptMultipleThreads();
+ void QTBUG13810_exitAndStart();
+
void stressTest();
};
@@ -934,6 +937,44 @@ void tst_QThread::stressTest()
}
}
+class Syncronizer : public QObject
+{ Q_OBJECT
+public slots:
+ void setProp(int p) {
+ if(m_prop != p) {
+ m_prop = p;
+ emit propChanged(p);
+ }
+ }
+signals:
+ void propChanged(int);
+public:
+ Syncronizer() : m_prop(42) {}
+ int m_prop;
+};
+
+void tst_QThread::QTBUG13810_exitAndStart()
+{
+ QThread thread;
+ thread.exit(555); //should do nothing
+
+ thread.start();
+
+ //test that the thread is running by executing queued connected signal there
+ Syncronizer sync1;
+ sync1.moveToThread(&thread);
+ Syncronizer sync2;
+ sync2.moveToThread(&thread);
+ connect(&sync2, SIGNAL(propChanged(int)), &sync1, SLOT(setProp(int)), Qt::QueuedConnection);
+ connect(&sync1, SIGNAL(propChanged(int)), &thread, SLOT(quit()), Qt::QueuedConnection);
+ QMetaObject::invokeMethod(&sync2, "setProp", Qt::QueuedConnection , Q_ARG(int, 89));
+ QTest::qWait(50);
+ while(!thread.wait(10))
+ QTest::qWait(10);
+ QCOMPARE(sync2.m_prop, 89);
+ QCOMPARE(sync1.m_prop, 89);
+}
+
QTEST_MAIN(tst_QThread)
#include "tst_qthread.moc"