diff options
author | axis <qt-info@nokia.com> | 2010-09-21 09:39:32 (GMT) |
---|---|---|
committer | axis <qt-info@nokia.com> | 2010-09-23 12:36:11 (GMT) |
commit | 1dcef0480901ec736af70edc80d4b821e0c8ebe5 (patch) | |
tree | 800a38f5974a7719e458c37dd697687fda921bf6 /tests | |
parent | 7f11c900e9184565321c09533b468abb047129b8 (diff) | |
download | Qt-1dcef0480901ec736af70edc80d4b821e0c8ebe5.zip Qt-1dcef0480901ec736af70edc80d4b821e0c8ebe5.tar.gz Qt-1dcef0480901ec736af70edc80d4b821e0c8ebe5.tar.bz2 |
Made posted events part of the round robin queue.
That means that posted events will only be sent once per event queue
iteration, just like timers. This helps prevent event starvation.
RevBy: mread
AutoTest: Included
Task: QTBUG-13743
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qtimer/tst_qtimer.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/auto/qtimer/tst_qtimer.cpp b/tests/auto/qtimer/tst_qtimer.cpp index f23d065..102308e 100644 --- a/tests/auto/qtimer/tst_qtimer.cpp +++ b/tests/auto/qtimer/tst_qtimer.cpp @@ -89,6 +89,7 @@ private slots: void recurseOnTimeoutAndStopTimer(); void QTBUG13633_dontBlockEvents(); + void postedEventsShouldNotStarveTimers(); }; class TimerHelper : public QObject @@ -723,5 +724,31 @@ void tst_QTimer::QTBUG13633_dontBlockEvents() QVERIFY(t.total > 2); } +class SlotRepeater : public QObject { + Q_OBJECT +public: + SlotRepeater() {} + +public slots: + void repeatThisSlot() + { + QMetaObject::invokeMethod(this, "repeatThisSlot", Qt::QueuedConnection); + } +}; + +void tst_QTimer::postedEventsShouldNotStarveTimers() +{ + TimerHelper timerHelper; + QTimer timer; + connect(&timer, SIGNAL(timeout()), &timerHelper, SLOT(timeout())); + timer.setInterval(0); + timer.setSingleShot(false); + timer.start(); + SlotRepeater slotRepeater; + slotRepeater.repeatThisSlot(); + QTest::qWait(100); + QVERIFY(timerHelper.count > 5); +} + QTEST_MAIN(tst_QTimer) #include "tst_qtimer.moc" |