qeventloop.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/kernel/qeventloop.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2015 The Qt Company Ltd.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtCore module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
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 The Qt Company. For licensing terms-
14** and conditions see http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34#include "qeventloop.h"-
35-
36#include "qabstracteventdispatcher.h"-
37#include "qcoreapplication.h"-
38#include "qcoreapplication_p.h"-
39#include "qelapsedtimer.h"-
40-
41#include "qobject_p.h"-
42#include "qeventloop_p.h"-
43#include <private/qthread_p.h>-
44-
45QT_BEGIN_NAMESPACE-
46-
47/*!-
48 \class QEventLoop-
49 \inmodule QtCore-
50 \brief The QEventLoop class provides a means of entering and leaving an event loop.-
51-
52 At any time, you can create a QEventLoop object and call exec()-
53 on it to start a local event loop. From within the event loop,-
54 calling exit() will force exec() to return.-
55-
56 \sa QAbstractEventDispatcher-
57*/-
58-
59/*!-
60 \enum QEventLoop::ProcessEventsFlag-
61-
62 This enum controls the types of events processed by the-
63 processEvents() functions.-
64-
65 \value AllEvents All events. Note that-
66 \l{QEvent::DeferredDelete}{DeferredDelete} events are processed-
67 specially. See QObject::deleteLater() for more details.-
68-
69 \value ExcludeUserInputEvents Do not process user input events,-
70 such as ButtonPress and KeyPress. Note that the events are not-
71 discarded; they will be delivered the next time processEvents() is-
72 called without the ExcludeUserInputEvents flag.-
73-
74 \value ExcludeSocketNotifiers Do not process socket notifier-
75 events. Note that the events are not discarded; they will be-
76 delivered the next time processEvents() is called without the-
77 ExcludeSocketNotifiers flag.-
78-
79 \value WaitForMoreEvents Wait for events if no pending events are-
80 available.-
81-
82 \omitvalue X11ExcludeTimers-
83 \omitvalue EventLoopExec-
84 \omitvalue DialogExec-
85-
86 \sa processEvents()-
87*/-
88-
89/*!-
90 Constructs an event loop object with the given \a parent.-
91*/-
92QEventLoop::QEventLoop(QObject *parent)-
93 : QObject(*new QEventLoopPrivate, parent)-
94{-
95 Q_D(QEventLoop);-
96 if (!QCoreApplication::instance() && QCoreApplicationPrivate::threadRequiresCoreApplication()) {
!QCoreApplication::instance()Description
TRUEevaluated 3 times by 3 tests
Evaluated by:
  • tst_QCoreApplication
  • tst_QDBusConnection_NoApplication
  • tst_QGuiApplication
FALSEevaluated 3970 times by 185 tests
Evaluated by:
  • tst_Gestures
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • ...
QCoreApplicati...eApplication()Description
TRUEnever evaluated
FALSEevaluated 3 times by 3 tests
Evaluated by:
  • tst_QCoreApplication
  • tst_QDBusConnection_NoApplication
  • tst_QGuiApplication
0-3970
97 qWarning("QEventLoop: Cannot be used without QApplication");-
98 } else if (!d->threadData->eventDispatcher.load()) {
never executed: end of block
!d->threadData...patcher.load()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QThread
FALSEevaluated 3971 times by 186 tests
Evaluated by:
  • tst_Gestures
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • ...
0-3971
99 QThreadPrivate::createEventDispatcher(d->threadData);-
100 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_QThread
2
101}
executed 3973 times by 186 tests: end of block
Executed by:
  • tst_Gestures
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • ...
3973
102-
103/*!-
104 Destroys the event loop object.-
105*/-
106QEventLoop::~QEventLoop()-
107{ }-
108-
109-
110/*!-
111 Processes pending events that match \a flags until there are no-
112 more events to process. Returns \c true if pending events were handled;-
113 otherwise returns \c false.-
114-
115 This function is especially useful if you have a long running-
116 operation and want to show its progress without allowing user-
117 input; i.e. by using the \l ExcludeUserInputEvents flag.-
118-
119 This function is simply a wrapper for-
120 QAbstractEventDispatcher::processEvents(). See the documentation-
121 for that function for details.-
122*/-
123bool QEventLoop::processEvents(ProcessEventsFlags flags)-
124{-
125 Q_D(QEventLoop);-
126 if (!d->threadData->eventDispatcher.load())
!d->threadData...patcher.load()Description
TRUEnever evaluated
FALSEevaluated 219741 times by 340 tests
Evaluated by:
  • tst_Gestures
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • ...
0-219741
127 return false;
never executed: return false;
0
128 return d->threadData->eventDispatcher.load()->processEvents(flags);
executed 219741 times by 340 tests: return d->threadData->eventDispatcher.load()->processEvents(flags);
Executed by:
  • tst_Gestures
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • ...
219741
129}-
130-
131/*!-
132 Enters the main event loop and waits until exit() is called.-
133 Returns the value that was passed to exit().-
134-
135 If \a flags are specified, only events of the types allowed by-
136 the \a flags will be processed.-
137-
138 It is necessary to call this function to start event handling. The-
139 main event loop receives events from the window system and-
140 dispatches these to the application widgets.-
141-
142 Generally speaking, no user interaction can take place before-
143 calling exec(). As a special case, modal widgets like QMessageBox-
144 can be used before calling exec(), because modal widgets-
145 use their own local event loop.-
146-
147 To make your application perform idle processing (i.e. executing a-
148 special function whenever there are no pending events), use a-
149 QTimer with 0 timeout. More sophisticated idle processing schemes-
150 can be achieved using processEvents().-
151-
152 \sa QCoreApplication::quit(), exit(), processEvents()-
153*/-
154int QEventLoop::exec(ProcessEventsFlags flags)-
155{-
156 Q_D(QEventLoop);-
157 //we need to protect from race condition with QThread::exit-
158 QMutexLocker locker(&static_cast<QThreadPrivate *>(QObjectPrivate::get(d->threadData->thread))->mutex);-
159 if (d->threadData->quitNow)
d->threadData->quitNowDescription
TRUEevaluated 7 times by 3 tests
Evaluated by:
  • tst_QEventLoop
  • tst_QGuiEventLoop
  • tst_QThread
FALSEevaluated 4044 times by 186 tests
Evaluated by:
  • tst_Gestures
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • ...
7-4044
160 return -1;
executed 7 times by 3 tests: return -1;
Executed by:
  • tst_QEventLoop
  • tst_QGuiEventLoop
  • tst_QThread
7
161-
162 if (d->inExec) {
d->inExecDescription
TRUEevaluated 2 times by 2 tests
Evaluated by:
  • tst_QEventLoop
  • tst_QGuiEventLoop
FALSEevaluated 4042 times by 186 tests
Evaluated by:
  • tst_Gestures
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • ...
2-4042
163 qWarning("QEventLoop::exec: instance %p has already called exec()", this);-
164 return -1;
executed 2 times by 2 tests: return -1;
Executed by:
  • tst_QEventLoop
  • tst_QGuiEventLoop
2
165 }-
166-
167 struct LoopReference {-
168 QEventLoopPrivate *d;-
169 QMutexLocker &locker;-
170-
171 bool exceptionCaught;-
172 LoopReference(QEventLoopPrivate *d, QMutexLocker &locker) : d(d), locker(locker), exceptionCaught(true)-
173 {-
174 d->inExec = true;-
175 d->exit.storeRelease(false);-
176 ++d->threadData->loopLevel;-
177 d->threadData->eventLoops.push(d->q_func());-
178 locker.unlock();-
179 }
executed 4042 times by 186 tests: end of block
Executed by:
  • tst_Gestures
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • ...
4042
180-
181 ~LoopReference()-
182 {-
183 if (exceptionCaught) {
exceptionCaughtDescription
TRUEnever evaluated
FALSEevaluated 4046 times by 238 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QAbstractScrollArea
  • tst_QApplication
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QColorDialog
  • tst_QCommandLinkButton
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusAbstractInterface
  • tst_QDBusConnection
  • tst_QDBusConnection_Delayed
  • tst_QDBusConnection_SpyHook
  • tst_QDBusInterface
  • tst_QDBusMarshall
  • tst_QDBusPendingCall
  • tst_QDBusServiceWatcher
  • tst_QDBusThreading
  • tst_QDialog
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QEventLoop
  • tst_QFileDialog2
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • ...
0-4046
184 qWarning("Qt has caught an exception thrown from an event handler. Throwing\n"-
185 "exceptions from an event handler is not supported in Qt.\n"-
186 "You must not let any exception whatsoever propagate through Qt code.\n"-
187 "If that is not possible, in Qt 5 you must at least reimplement\n"-
188 "QCoreApplication::notify() and catch all exceptions there.\n");-
189 }
never executed: end of block
0
190 locker.relock();-
191 QEventLoop *eventLoop = d->threadData->eventLoops.pop();-
192 Q_ASSERT_X(eventLoop == d->q_func(), "QEventLoop::exec()", "internal error");-
193 Q_UNUSED(eventLoop); // --release warning-
194 d->inExec = false;-
195 --d->threadData->loopLevel;-
196 }
executed 4046 times by 238 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QAbstractScrollArea
  • tst_QApplication
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QColorDialog
  • tst_QCommandLinkButton
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusAbstractInterface
  • tst_QDBusConnection
  • tst_QDBusConnection_Delayed
  • tst_QDBusConnection_SpyHook
  • tst_QDBusInterface
  • tst_QDBusMarshall
  • tst_QDBusPendingCall
  • tst_QDBusServiceWatcher
  • tst_QDBusThreading
  • tst_QDialog
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QEventLoop
  • tst_QFileDialog2
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • ...
4046
197 };-
198 LoopReference ref(d, locker);-
199-
200 // remove posted quit events when entering a new event loop-
201 QCoreApplication *app = QCoreApplication::instance();-
202 if (app && app->thread() == thread())
appDescription
TRUEevaluated 4039 times by 185 tests
Evaluated by:
  • tst_Gestures
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • ...
FALSEevaluated 3 times by 3 tests
Evaluated by:
  • tst_QCoreApplication
  • tst_QDBusConnection_NoApplication
  • tst_QGuiApplication
app->thread() == thread()Description
TRUEevaluated 3019 times by 77 tests
Evaluated by:
  • tst_QAbstractScrollArea
  • tst_QApplication
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QColorDialog
  • tst_QCommandLinkButton
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusAbstractInterface
  • tst_QDBusConnection
  • tst_QDBusConnection_Delayed
  • tst_QDBusConnection_SpyHook
  • tst_QDBusInterface
  • tst_QDBusMarshall
  • tst_QDBusPendingCall
  • tst_QDBusServiceWatcher
  • tst_QDBusThreading
  • tst_QDialog
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QEventLoop
  • tst_QFileDialog2
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QFontDialog
  • ...
FALSEevaluated 1020 times by 172 tests
Evaluated by:
  • tst_Gestures
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusAbstractInterface
  • ...
3-4039
203 QCoreApplication::removePostedEvents(app, QEvent::Quit);
executed 3019 times by 77 tests: QCoreApplication::removePostedEvents(app, QEvent::Quit);
Executed by:
  • tst_QAbstractScrollArea
  • tst_QApplication
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QColorDialog
  • tst_QCommandLinkButton
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusAbstractInterface
  • tst_QDBusConnection
  • tst_QDBusConnection_Delayed
  • tst_QDBusConnection_SpyHook
  • tst_QDBusInterface
  • tst_QDBusMarshall
  • tst_QDBusPendingCall
  • tst_QDBusServiceWatcher
  • tst_QDBusThreading
  • tst_QDialog
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QEventLoop
  • tst_QFileDialog2
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QFontDialog
  • ...
3019
204-
205 while (!d->exit.loadAcquire())
!d->exit.loadAcquire()Description
TRUEevaluated 219129 times by 340 tests
Evaluated by:
  • tst_Gestures
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • ...
FALSEevaluated 4046 times by 238 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QAbstractScrollArea
  • tst_QApplication
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QColorDialog
  • tst_QCommandLinkButton
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusAbstractInterface
  • tst_QDBusConnection
  • tst_QDBusConnection_Delayed
  • tst_QDBusConnection_SpyHook
  • tst_QDBusInterface
  • tst_QDBusMarshall
  • tst_QDBusPendingCall
  • tst_QDBusServiceWatcher
  • tst_QDBusThreading
  • tst_QDialog
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QEventLoop
  • tst_QFileDialog2
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • ...
4046-219129
206 processEvents(flags | WaitForMoreEvents | EventLoopExec);
executed 219129 times by 340 tests: processEvents(flags | WaitForMoreEvents | EventLoopExec);
Executed by:
  • tst_Gestures
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • ...
219129
207-
208 ref.exceptionCaught = false;-
209 return d->returnCode.load();
executed 4046 times by 238 tests: return d->returnCode.load();
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QAbstractScrollArea
  • tst_QApplication
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QColorDialog
  • tst_QCommandLinkButton
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusAbstractInterface
  • tst_QDBusConnection
  • tst_QDBusConnection_Delayed
  • tst_QDBusConnection_SpyHook
  • tst_QDBusInterface
  • tst_QDBusMarshall
  • tst_QDBusPendingCall
  • tst_QDBusServiceWatcher
  • tst_QDBusThreading
  • tst_QDialog
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QEventLoop
  • tst_QFileDialog2
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • ...
4046
210}-
211-
212/*!-
213 Process pending events that match \a flags for a maximum of \a-
214 maxTime milliseconds, or until there are no more events to-
215 process, whichever is shorter.-
216 This function is especially useful if you have a long running-
217 operation and want to show its progress without allowing user-
218 input, i.e. by using the \l ExcludeUserInputEvents flag.-
219-
220 \b{Notes:}-
221 \list-
222 \li This function does not process events continuously; it-
223 returns after all available events are processed.-
224 \li Specifying the \l WaitForMoreEvents flag makes no sense-
225 and will be ignored.-
226 \endlist-
227*/-
228void QEventLoop::processEvents(ProcessEventsFlags flags, int maxTime)-
229{-
230 Q_D(QEventLoop);-
231 if (!d->threadData->eventDispatcher.load())
!d->threadData...patcher.load()Description
TRUEnever evaluated
FALSEnever evaluated
0
232 return;
never executed: return;
0
233-
234 QElapsedTimer start;-
235 start.start();-
236 while (processEvents(flags & ~WaitForMoreEvents)) {
processEvents(...ForMoreEvents)Description
TRUEnever evaluated
FALSEnever evaluated
0
237 if (start.elapsed() > maxTime)
start.elapsed() > maxTimeDescription
TRUEnever evaluated
FALSEnever evaluated
0
238 break;
never executed: break;
0
239 }
never executed: end of block
0
240}
never executed: end of block
0
241-
242/*!-
243 Tells the event loop to exit with a return code.-
244-
245 After this function has been called, the event loop returns from-
246 the call to exec(). The exec() function returns \a returnCode.-
247-
248 By convention, a \a returnCode of 0 means success, and any non-zero-
249 value indicates an error.-
250-
251 Note that unlike the C library function of the same name, this-
252 function \e does return to the caller -- it is event processing that-
253 stops.-
254-
255 \sa QCoreApplication::quit(), quit(), exec()-
256*/-
257void QEventLoop::exit(int returnCode)-
258{-
259 Q_D(QEventLoop);-
260 if (!d->threadData->eventDispatcher.load())
!d->threadData...patcher.load()Description
TRUEnever evaluated
FALSEevaluated 4387 times by 238 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QAbstractScrollArea
  • tst_QApplication
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QColorDialog
  • tst_QCommandLinkButton
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusAbstractInterface
  • tst_QDBusConnection
  • tst_QDBusConnection_Delayed
  • tst_QDBusConnection_SpyHook
  • tst_QDBusInterface
  • tst_QDBusMarshall
  • tst_QDBusPendingCall
  • tst_QDBusServiceWatcher
  • tst_QDBusThreading
  • tst_QDialog
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QEventLoop
  • tst_QFileDialog2
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • ...
0-4387
261 return;
never executed: return;
0
262-
263 d->returnCode.store(returnCode);-
264 d->exit.storeRelease(true);-
265 d->threadData->eventDispatcher.load()->interrupt();-
266}
executed 4387 times by 238 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QAbstractScrollArea
  • tst_QApplication
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QColorDialog
  • tst_QCommandLinkButton
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusAbstractInterface
  • tst_QDBusConnection
  • tst_QDBusConnection_Delayed
  • tst_QDBusConnection_SpyHook
  • tst_QDBusInterface
  • tst_QDBusMarshall
  • tst_QDBusPendingCall
  • tst_QDBusServiceWatcher
  • tst_QDBusThreading
  • tst_QDialog
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QEventLoop
  • tst_QFileDialog2
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • ...
4387
267-
268/*!-
269 Returns \c true if the event loop is running; otherwise returns-
270 false. The event loop is considered running from the time when-
271 exec() is called until exit() is called.-
272-
273 \sa exec(), exit()-
274 */-
275bool QEventLoop::isRunning() const-
276{-
277 Q_D(const QEventLoop);-
278 return !d->exit.loadAcquire();
executed 8 times by 1 test: return !d->exit.loadAcquire();
Executed by:
  • tst_QGraphicsView
8
279}-
280-
281/*!-
282 Wakes up the event loop.-
283-
284 \sa QAbstractEventDispatcher::wakeUp()-
285*/-
286void QEventLoop::wakeUp()-
287{-
288 Q_D(QEventLoop);-
289 if (!d->threadData->eventDispatcher.load())
!d->threadData...patcher.load()Description
TRUEnever evaluated
FALSEevaluated 2 times by 2 tests
Evaluated by:
  • tst_QEventLoop
  • tst_QGuiEventLoop
0-2
290 return;
never executed: return;
0
291 d->threadData->eventDispatcher.load()->wakeUp();-
292}
executed 2 times by 2 tests: end of block
Executed by:
  • tst_QEventLoop
  • tst_QGuiEventLoop
2
293-
294-
295/*!-
296 \reimp-
297*/-
298bool QEventLoop::event(QEvent *event)-
299{-
300 if (event->type() == QEvent::Quit) {
event->type() == QEvent::QuitDescription
TRUEevaluated 4 times by 2 tests
Evaluated by:
  • tst_QEventLoop
  • tst_QGuiEventLoop
FALSEevaluated 338 times by 14 tests
Evaluated by:
  • tst_QApplication
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusAbstractInterface
  • tst_QDBusConnection
  • tst_QDBusConnection_SpyHook
  • tst_QEventLoop
  • tst_QGuiApplication
  • tst_QGuiEventLoop
  • tst_QNetworkReply
  • tst_QObject
  • tst_QProcess
  • tst_QThread
  • tst_QTimer
4-338
301 quit();-
302 return true;
executed 4 times by 2 tests: return true;
Executed by:
  • tst_QEventLoop
  • tst_QGuiEventLoop
4
303 } else {-
304 return QObject::event(event);
executed 338 times by 14 tests: return QObject::event(event);
Executed by:
  • tst_QApplication
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusAbstractInterface
  • tst_QDBusConnection
  • tst_QDBusConnection_SpyHook
  • tst_QEventLoop
  • tst_QGuiApplication
  • tst_QGuiEventLoop
  • tst_QNetworkReply
  • tst_QObject
  • tst_QProcess
  • tst_QThread
  • tst_QTimer
338
305 }-
306}-
307-
308/*!-
309 Tells the event loop to exit normally.-
310-
311 Same as exit(0).-
312-
313 \sa QCoreApplication::quit(), exit()-
314*/-
315void QEventLoop::quit()-
316{
executed 639 times by 26 tests: exit(0);
Executed by:
  • tst_QApplication
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusAbstractInterface
  • tst_QDBusConnection
  • tst_QDBusConnection_SpyHook
  • tst_QDBusMarshall
  • tst_QEventLoop
  • tst_QFileSystemWatcher
  • tst_QFtp
  • tst_QGraphicsView
  • tst_QGuiApplication
  • tst_QGuiEventLoop
  • tst_QImageReader
  • tst_QNetworkReply
  • tst_QObject
  • tst_QProcess
  • tst_QProgressBar
  • tst_QSslSocket
  • tst_QTcpServer
  • tst_QTcpSocket
  • tst_QThread
  • tst_QTimeLine
  • tst_QTimer
  • tst_QWidget
  • ...
exit(0); }
executed 639 times by 26 tests: exit(0);
Executed by:
  • tst_QApplication
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • tst_QDBusAbstractInterface
  • tst_QDBusConnection
  • tst_QDBusConnection_SpyHook
  • tst_QDBusMarshall
  • tst_QEventLoop
  • tst_QFileSystemWatcher
  • tst_QFtp
  • tst_QGraphicsView
  • tst_QGuiApplication
  • tst_QGuiEventLoop
  • tst_QImageReader
  • tst_QNetworkReply
  • tst_QObject
  • tst_QProcess
  • tst_QProgressBar
  • tst_QSslSocket
  • tst_QTcpServer
  • tst_QTcpSocket
  • tst_QThread
  • tst_QTimeLine
  • tst_QTimer
  • tst_QWidget
  • ...
639
317-
318-
319class QEventLoopLockerPrivate-
320{-
321public:-
322 explicit QEventLoopLockerPrivate(QEventLoopPrivate *loop)-
323 : loop(loop), type(EventLoop)-
324 {-
325 loop->ref();-
326 }
executed 22 times by 2 tests: end of block
Executed by:
  • tst_QEventLoop
  • tst_QGuiEventLoop
22
327-
328 explicit QEventLoopLockerPrivate(QThreadPrivate *thread)-
329 : thread(thread), type(Thread)-
330 {-
331 thread->ref();-
332 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_QThread
2
333-
334 explicit QEventLoopLockerPrivate(QCoreApplicationPrivate *app)-
335 : app(app), type(Application)-
336 {-
337 app->ref();-
338 }
executed 12 times by 2 tests: end of block
Executed by:
  • tst_QCoreApplication
  • tst_QGuiApplication
12
339-
340 ~QEventLoopLockerPrivate()-
341 {-
342 switch (type)-
343 {-
344 case EventLoop:
executed 22 times by 2 tests: case EventLoop:
Executed by:
  • tst_QEventLoop
  • tst_QGuiEventLoop
22
345 loop->deref();-
346 break;
executed 22 times by 2 tests: break;
Executed by:
  • tst_QEventLoop
  • tst_QGuiEventLoop
22
347 case Thread:
executed 1 time by 1 test: case Thread:
Executed by:
  • tst_QThread
1
348 thread->deref();-
349 break;
executed 1 time by 1 test: break;
Executed by:
  • tst_QThread
1
350 default:
executed 12 times by 2 tests: default:
Executed by:
  • tst_QCoreApplication
  • tst_QGuiApplication
12
351 app->deref();-
352 break;
executed 12 times by 2 tests: break;
Executed by:
  • tst_QCoreApplication
  • tst_QGuiApplication
12
353 }-
354 }-
355-
356private:-
357 union {-
358 QEventLoopPrivate * loop;-
359 QThreadPrivate * thread;-
360 QCoreApplicationPrivate * app;-
361 };-
362 enum Type {-
363 EventLoop,-
364 Thread,-
365 Application-
366 };-
367 const Type type;-
368};-
369-
370/*!-
371 \class QEventLoopLocker-
372 \inmodule QtCore-
373 \brief The QEventLoopLocker class provides a means to quit an event loop when it is no longer needed.-
374 \since 5.0-
375-
376 The QEventLoopLocker operates on particular objects - either a QCoreApplication-
377 instance, a QEventLoop instance or a QThread instance.-
378-
379 This makes it possible to, for example, run a batch of jobs with an event loop-
380 and exit that event loop after the last job is finished. That is accomplished-
381 by keeping a QEventLoopLocker with each job instance.-
382-
383 The variant which operates on QCoreApplication makes it possible to finish-
384 asynchronously running jobs after the last gui window has been closed. This-
385 can be useful for example for running a job which uploads data to a network.-
386-
387 \sa QEventLoop, QCoreApplication-
388*/-
389-
390/*!-
391 Creates an event locker operating on the QCoreApplication.-
392-
393 The application will quit when there are no more QEventLoopLockers operating on it.-
394-
395 \sa QCoreApplication::quit(), QCoreApplication::isQuitLockEnabled()-
396 */-
397QEventLoopLocker::QEventLoopLocker()-
398 : d_ptr(new QEventLoopLockerPrivate(static_cast<QCoreApplicationPrivate*>(QObjectPrivate::get(QCoreApplication::instance()))))-
399{-
400-
401}
executed 12 times by 2 tests: end of block
Executed by:
  • tst_QCoreApplication
  • tst_QGuiApplication
12
402-
403/*!-
404 Creates an event locker operating on the \a loop.-
405-
406 This particular QEventLoop will quit when there are no more QEventLoopLockers operating on it.-
407-
408 \sa QEventLoop::quit()-
409 */-
410QEventLoopLocker::QEventLoopLocker(QEventLoop *loop)-
411 : d_ptr(new QEventLoopLockerPrivate(static_cast<QEventLoopPrivate*>(QObjectPrivate::get(loop))))-
412{-
413-
414}
executed 22 times by 2 tests: end of block
Executed by:
  • tst_QEventLoop
  • tst_QGuiEventLoop
22
415-
416/*!-
417 Creates an event locker operating on the \a thread.-
418-
419 This particular QThread will quit when there are no more QEventLoopLockers operating on it.-
420-
421 \sa QThread::quit()-
422 */-
423QEventLoopLocker::QEventLoopLocker(QThread *thread)-
424 : d_ptr(new QEventLoopLockerPrivate(static_cast<QThreadPrivate*>(QObjectPrivate::get(thread))))-
425{-
426-
427}
executed 2 times by 1 test: end of block
Executed by:
  • tst_QThread
2
428-
429/*!-
430 Destroys this event loop locker object-
431 */-
432QEventLoopLocker::~QEventLoopLocker()-
433{-
434 delete d_ptr;-
435}
executed 35 times by 5 tests: end of block
Executed by:
  • tst_QCoreApplication
  • tst_QEventLoop
  • tst_QGuiApplication
  • tst_QGuiEventLoop
  • tst_QThread
35
436-
437QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9