diff options
author | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2014-11-10 14:26:34 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2014-11-11 06:28:11 +0100 |
commit | 014785d8533f9fe021edfe5075a3c89494f0fe8d (patch) | |
tree | cf3597293d93fcd83695ca27f979ddb086881b0a /tests/auto/corelib/kernel/qtimer | |
parent | ba73bde66efa588a74eaaa946e80e9de2b9e2d59 (diff) |
tst_QTimer::singleShotToFunctors: Allocate static event loop on heap.
Fix warning:
QEventLoop: Cannot be used without QApplication
and occasional crashes on Windows.
Task-number: QTBUG-26406
Change-Id: Ia8b2a4e3d375d1e43f0e66fe64a39af5f9cf4d60
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Reviewed-by: Dario Freddi <dario.freddi@ispirata.com>
Diffstat (limited to 'tests/auto/corelib/kernel/qtimer')
-rw-r--r-- | tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp index 78c75b44e8..5833123dfe 100644 --- a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp +++ b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp @@ -642,18 +642,25 @@ struct CountedStruct QThread *thread; }; -static QEventLoop _e; +static QScopedPointer<QEventLoop> _e; static QThread *_t = Q_NULLPTR; class StaticEventLoop { public: - static void quitEventLoop() { _e.quit(); if (_t) QCOMPARE(QThread::currentThread(), _t); } + static void quitEventLoop() + { + QVERIFY(!_e.isNull()); + _e->quit(); + if (_t) + QCOMPARE(QThread::currentThread(), _t); + } }; void tst_QTimer::singleShotToFunctors() { int count = 0; + _e.reset(new QEventLoop); QEventLoop e; QTimer::singleShot(0, CountedStruct(&count)); @@ -661,7 +668,7 @@ void tst_QTimer::singleShotToFunctors() QCOMPARE(count, 1); QTimer::singleShot(0, &StaticEventLoop::quitEventLoop); - QCOMPARE(_e.exec(), 0); + QCOMPARE(_e->exec(), 0); QThread t1; QObject c1; @@ -687,7 +694,7 @@ void tst_QTimer::singleShotToFunctors() QCOMPARE(e.exec(), 0); QTimer::singleShot(0, &c2, &StaticEventLoop::quitEventLoop); - QCOMPARE(_e.exec(), 0); + QCOMPARE(_e->exec(), 0); _t->quit(); _t->wait(); @@ -721,8 +728,10 @@ void tst_QTimer::singleShotToFunctors() thread.quit(); thread.wait(); #endif -} + _e.reset(); + _t = Q_NULLPTR; +} class DontBlockEvents : public QObject { |