From: Ivailo Monev Date: Sat, 23 Nov 2019 17:20:10 +0000 (+0000) Subject: QTestEventLoop cleanup X-Git-Tag: 4.12.0~5045 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=f1f94f856a4c7f48aae51d0923dc129969c2eb76;p=kde%2FKatie.git QTestEventLoop cleanup Signed-off-by: Ivailo Monev --- diff --git a/src/test/qtesteventloop.h b/src/test/qtesteventloop.h index 6daa1084c..65f0e7348 100644 --- a/src/test/qtesteventloop.h +++ b/src/test/qtesteventloop.h @@ -50,7 +50,7 @@ class Q_TEST_EXPORT QTestEventLoop : public QObject public: inline QTestEventLoop(QObject *aParent = 0) - : QObject(aParent), inLoop(false), _timeout(false), timerId(-1), loop(0) {} + : QObject(aParent), _timeout(false), timerId(-1) {} inline void enterLoop(int secs); @@ -69,53 +69,44 @@ public: } public Q_SLOTS: - inline void exitLoop(); + void exitLoop(); protected: - inline void timerEvent(QTimerEvent *e); + void timerEvent(QTimerEvent *e); private: - bool inLoop; bool _timeout; int timerId; - QEventLoop *loop; + QEventLoop loop; }; -inline void QTestEventLoop::enterLoop(int secs) +void QTestEventLoop::enterLoop(int secs) { - Q_ASSERT(!loop); + Q_ASSERT(!loop.isRunning()); - QEventLoop l; - - inLoop = true; _timeout = false; - timerId = startTimer(secs * 1000); - loop = &l; - l.exec(); - loop = 0; + loop.exec(); } -inline void QTestEventLoop::exitLoop() +void QTestEventLoop::exitLoop() { if (timerId != -1) killTimer(timerId); - timerId = -1; - if (loop) - loop->exit(); + timerId = -1; - inLoop = false; + loop.exit(); } -inline void QTestEventLoop::timerEvent(QTimerEvent *e) +void QTestEventLoop::timerEvent(QTimerEvent *e) { - if (e->timerId() != timerId) - return; - _timeout = true; - exitLoop(); + if (e->timerId() == timerId) { + _timeout = true; + exitLoop(); + } } QT_END_NAMESPACE