49 #include <private/qthread_p.h>
104 qWarning(
"QEventLoop: Cannot be used without QApplication");
106 d->threadData.loadRelaxed()->ensureEventDispatcher();
133 auto threadData =
d->threadData.loadRelaxed();
134 if (!threadData->hasEventDispatcher())
136 return threadData->eventDispatcher.loadRelaxed()->processEvents(
flags);
165 auto threadData =
d->threadData.loadRelaxed();
169 if (threadData->quitNow)
173 qWarning(
"QEventLoop::exec: instance %p has already called exec()",
this);
177 struct LoopReference {
181 bool exceptionCaught;
185 d->exit.storeRelease(
false);
187 auto threadData =
d->threadData.loadRelaxed();
188 ++threadData->loopLevel;
189 threadData->eventLoops.push(
d->q_func());
196 if (exceptionCaught) {
197 qWarning(
"Qt has caught an exception thrown from an event handler. Throwing\n"
198 "exceptions from an event handler is not supported in Qt.\n"
199 "You must not let any exception whatsoever propagate through Qt code.");
202 auto threadData =
d->threadData.loadRelaxed();
203 QEventLoop *eventLoop = threadData->eventLoops.pop();
204 Q_ASSERT_X(eventLoop ==
d->q_func(),
"QEventLoop::exec()",
"internal error");
207 --threadData->loopLevel;
210 LoopReference
ref(
d, locker);
217 while (!
d->exit.loadAcquire())
220 ref.exceptionCaught =
false;
221 return d->returnCode.loadRelaxed();
243 if (!
d->threadData.loadRelaxed()->hasEventDispatcher())
249 if (
start.elapsed() > maxTime)
272 auto threadData =
d->threadData.loadAcquire();
273 if (!threadData->hasEventDispatcher())
276 d->returnCode.storeRelaxed(returnCode);
277 d->exit.storeRelease(
true);
278 threadData->eventDispatcher.loadRelaxed()->interrupt();
291 return !
d->exit.loadAcquire();
302 auto threadData =
d->threadData.loadAcquire();
303 if (!threadData->hasEventDispatcher())
305 threadData->eventDispatcher.loadRelaxed()->wakeUp();
453 #include "moc_qeventloop.cpp"
The QCoreApplication class provides an event loop for Qt applications without UI.
static QCoreApplication * instance()
static void removePostedEvents(QObject *receiver, int eventType=0)
static bool threadRequiresCoreApplication()
The QElapsedTimer class provides a fast way to calculate elapsed times.
The QEvent class is the base class of all event classes. Event objects contain event parameters.
The QEventLoop class provides a means of entering and leaving an event loop.
int exec(ProcessEventsFlags flags=AllEvents)
void exit(int returnCode=0)
bool processEvents(ProcessEventsFlags flags=AllEvents)
bool event(QEvent *event) override
QEventLoop(QObject *parent=nullptr)
QEventLoopLockerPrivate(QThreadPrivate *thread)
QEventLoopLockerPrivate(QCoreApplicationPrivate *app)
QCoreApplicationPrivate * app
~QEventLoopLockerPrivate()
QEventLoopLockerPrivate(QEventLoopPrivate *loop)
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes.
The QObject class is the base class of all Qt objects.
virtual bool event(QEvent *event)
static QObjectPrivate * get(QObject *o)
#define Q_ASSERT_X(cond, x, msg)
QApplication app(argc, argv)
[0]
http get(QUrl::toPercentEncoding("/index.html"))
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent