| Line | Source Code | Coverage |
|---|
| 1 | /**************************************************************************** | - |
| 2 | ** | - |
| 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
| 4 | ** Contact: http://www.qt-project.org/legal | - |
| 5 | ** | - |
| 6 | ** This file is part of the QtCore module of the Qt Toolkit. | - |
| 7 | ** | - |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
| 9 | ** Commercial License Usage | - |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
| 11 | ** accordance with the commercial license agreement provided with the | - |
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - |
| 13 | ** a written agreement between you and Digia. For licensing terms and | - |
| 14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
| 15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
| 16 | ** | - |
| 17 | ** GNU Lesser General Public License Usage | - |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
| 19 | ** General Public License version 2.1 as published by the Free Software | - |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
| 21 | ** packaging of this file. Please review the following information to | - |
| 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
| 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
| 24 | ** | - |
| 25 | ** In addition, as a special exception, Digia gives you certain additional | - |
| 26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
| 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
| 28 | ** | - |
| 29 | ** GNU General Public License Usage | - |
| 30 | ** Alternatively, this file may be used under the terms of the GNU | - |
| 31 | ** General Public License version 3.0 as published by the Free Software | - |
| 32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
| 33 | ** packaging of this file. Please review the following information to | - |
| 34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
| 35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
| 36 | ** | - |
| 37 | ** | - |
| 38 | ** $QT_END_LICENSE$ | - |
| 39 | ** | - |
| 40 | ****************************************************************************/ | - |
| 41 | | - |
| 42 | #include "qbasictimer.h" | - |
| 43 | #include "qabstracteventdispatcher.h" | - |
| 44 | #include "qabstracteventdispatcher_p.h" | - |
| 45 | | - |
| 46 | QT_BEGIN_NAMESPACE | - |
| 47 | | - |
| 48 | /*! | - |
| 49 | \class QBasicTimer | - |
| 50 | \inmodule QtCore | - |
| 51 | \brief The QBasicTimer class provides timer events for objects. | - |
| 52 | | - |
| 53 | \ingroup events | - |
| 54 | | - |
| 55 | This is a fast, lightweight, and low-level class used by Qt | - |
| 56 | internally. We recommend using the higher-level QTimer class | - |
| 57 | rather than this class if you want to use timers in your | - |
| 58 | applications. Note that this timer is a repeating timer that | - |
| 59 | will send subsequent timer events unless the stop() function is called. | - |
| 60 | | - |
| 61 | To use this class, create a QBasicTimer, and call its start() | - |
| 62 | function with a timeout interval and with a pointer to a QObject | - |
| 63 | subclass. When the timer times out it will send a timer event to | - |
| 64 | the QObject subclass. The timer can be stopped at any time using | - |
| 65 | stop(). isActive() returns true for a timer that is running; | - |
| 66 | i.e. it has been started, has not reached the timeout time, and | - |
| 67 | has not been stopped. The timer's ID can be retrieved using | - |
| 68 | timerId(). | - |
| 69 | | - |
| 70 | The \l{widgets/wiggly}{Wiggly} example uses QBasicTimer to repaint | - |
| 71 | a widget at regular intervals. | - |
| 72 | | - |
| 73 | \sa QTimer, QTimerEvent, QObject::timerEvent(), Timers, {Wiggly Example} | - |
| 74 | */ | - |
| 75 | | - |
| 76 | | - |
| 77 | /*! | - |
| 78 | \fn QBasicTimer::QBasicTimer() | - |
| 79 | | - |
| 80 | Contructs a basic timer. | - |
| 81 | | - |
| 82 | \sa start() | - |
| 83 | */ | - |
| 84 | /*! | - |
| 85 | \fn QBasicTimer::~QBasicTimer() | - |
| 86 | | - |
| 87 | Destroys the basic timer. | - |
| 88 | */ | - |
| 89 | | - |
| 90 | /*! | - |
| 91 | \fn bool QBasicTimer::isActive() const | - |
| 92 | | - |
| 93 | Returns true if the timer is running and has not been stopped; otherwise | - |
| 94 | returns false. | - |
| 95 | | - |
| 96 | \sa start(), stop() | - |
| 97 | */ | - |
| 98 | | - |
| 99 | /*! | - |
| 100 | \fn int QBasicTimer::timerId() const | - |
| 101 | | - |
| 102 | Returns the timer's ID. | - |
| 103 | | - |
| 104 | \sa QTimerEvent::timerId() | - |
| 105 | */ | - |
| 106 | | - |
| 107 | /*! | - |
| 108 | \fn void QBasicTimer::start(int msec, QObject *object) | - |
| 109 | | - |
| 110 | Starts (or restarts) the timer with a \a msec milliseconds timeout. The | - |
| 111 | timer will be a Qt::CoarseTimer. See Qt::TimerType for information on the | - |
| 112 | different timer types. | - |
| 113 | | - |
| 114 | The given \a object will receive timer events. | - |
| 115 | | - |
| 116 | \sa stop(), isActive(), QObject::timerEvent(), Qt::CoarseTimer | - |
| 117 | */ | - |
| 118 | void QBasicTimer::start(int msec, QObject *obj) | - |
| 119 | { | - |
| 120 | QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance(); executed (the execution status of this line is deduced): QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance(); | - |
| 121 | if (!eventDispatcher) { partially evaluated: !eventDispatcher| no Evaluation Count:0 | yes Evaluation Count:120461 |
| 0-120461 |
| 122 | qWarning("QBasicTimer::start: QBasicTimer can only be used with threads started with QThread"); never executed (the execution status of this line is deduced): QMessageLogger("kernel/qbasictimer.cpp", 122, __PRETTY_FUNCTION__).warning("QBasicTimer::start: QBasicTimer can only be used with threads started with QThread"); | - |
| 123 | return; | 0 |
| 124 | } | - |
| 125 | if (id) { evaluated: id| yes Evaluation Count:103116 | yes Evaluation Count:17345 |
| 17345-103116 |
| 126 | eventDispatcher->unregisterTimer(id); executed (the execution status of this line is deduced): eventDispatcher->unregisterTimer(id); | - |
| 127 | QAbstractEventDispatcherPrivate::releaseTimerId(id); executed (the execution status of this line is deduced): QAbstractEventDispatcherPrivate::releaseTimerId(id); | - |
| 128 | } executed: }Execution Count:103116 | 103116 |
| 129 | id = 0; executed (the execution status of this line is deduced): id = 0; | - |
| 130 | if (obj) evaluated: obj| yes Evaluation Count:120272 | yes Evaluation Count:189 |
| 189-120272 |
| 131 | id = eventDispatcher->registerTimer(msec, Qt::CoarseTimer, obj); executed: id = eventDispatcher->registerTimer(msec, Qt::CoarseTimer, obj);Execution Count:120272 | 120272 |
| 132 | } executed: }Execution Count:120461 | 120461 |
| 133 | | - |
| 134 | /*! | - |
| 135 | \overload | - |
| 136 | | - |
| 137 | Starts (or restarts) the timer with a \a msec milliseconds timeout and the | - |
| 138 | given \a timerType. See Qt::TimerType for information on the different | - |
| 139 | timer types. | - |
| 140 | | - |
| 141 | \a obj will receive timer events. | - |
| 142 | | - |
| 143 | \sa stop(), isActive(), QObject::timerEvent(), Qt::TimerType | - |
| 144 | */ | - |
| 145 | void QBasicTimer::start(int msec, Qt::TimerType timerType, QObject *obj) | - |
| 146 | { | - |
| 147 | QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance(); executed (the execution status of this line is deduced): QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance(); | - |
| 148 | if (!eventDispatcher) { partially evaluated: !eventDispatcher| no Evaluation Count:0 | yes Evaluation Count:114 |
| 0-114 |
| 149 | qWarning("QBasicTimer::start: QBasicTimer can only be used with threads started with QThread"); never executed (the execution status of this line is deduced): QMessageLogger("kernel/qbasictimer.cpp", 149, __PRETTY_FUNCTION__).warning("QBasicTimer::start: QBasicTimer can only be used with threads started with QThread"); | - |
| 150 | return; | 0 |
| 151 | } | - |
| 152 | if (id) { evaluated: id| yes Evaluation Count:19 | yes Evaluation Count:95 |
| 19-95 |
| 153 | eventDispatcher->unregisterTimer(id); executed (the execution status of this line is deduced): eventDispatcher->unregisterTimer(id); | - |
| 154 | QAbstractEventDispatcherPrivate::releaseTimerId(id); executed (the execution status of this line is deduced): QAbstractEventDispatcherPrivate::releaseTimerId(id); | - |
| 155 | } executed: }Execution Count:19 | 19 |
| 156 | id = 0; executed (the execution status of this line is deduced): id = 0; | - |
| 157 | if (obj) partially evaluated: obj| yes Evaluation Count:114 | no Evaluation Count:0 |
| 0-114 |
| 158 | id = eventDispatcher->registerTimer(msec, timerType, obj); executed: id = eventDispatcher->registerTimer(msec, timerType, obj);Execution Count:114 | 114 |
| 159 | } executed: }Execution Count:114 | 114 |
| 160 | | - |
| 161 | /*! | - |
| 162 | Stops the timer. | - |
| 163 | | - |
| 164 | \sa start(), isActive() | - |
| 165 | */ | - |
| 166 | void QBasicTimer::stop() | - |
| 167 | { | - |
| 168 | if (id) { evaluated: id| yes Evaluation Count:15779 | yes Evaluation Count:139664 |
| 15779-139664 |
| 169 | QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance(); executed (the execution status of this line is deduced): QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance(); | - |
| 170 | if (eventDispatcher) evaluated: eventDispatcher| yes Evaluation Count:15776 | yes Evaluation Count:3 |
| 3-15776 |
| 171 | eventDispatcher->unregisterTimer(id); executed: eventDispatcher->unregisterTimer(id);Execution Count:15776 | 15776 |
| 172 | QAbstractEventDispatcherPrivate::releaseTimerId(id); executed (the execution status of this line is deduced): QAbstractEventDispatcherPrivate::releaseTimerId(id); | - |
| 173 | } executed: }Execution Count:15779 | 15779 |
| 174 | id = 0; executed (the execution status of this line is deduced): id = 0; | - |
| 175 | } executed: }Execution Count:155443 | 155443 |
| 176 | | - |
| 177 | QT_END_NAMESPACE | - |
| 178 | | - |
| | |