49 #include <private/qthread_p.h> 122 qWarning(
"QEventLoop: Cannot be used without QApplication");
123 }
else if (!
d->threadData->eventDispatcher) {
151 if (!
d->threadData->eventDispatcher)
155 return d->threadData->eventDispatcher->processEvents(flags);
186 if (
d->threadData->quitNow)
190 qWarning(
"QEventLoop::exec: instance %p has already called exec()",
this);
195 ++
d->threadData->loopLevel;
196 d->threadData->eventLoops.push(
this);
204 #if defined(QT_NO_EXCEPTIONS) 212 qWarning(
"Qt has caught an exception thrown from an event handler. Throwing\n" 213 "exceptions from an event handler is not supported in Qt. You must\n" 214 "reimplement QApplication::notify() and catch all exceptions there.\n");
218 QEventLoop *eventLoop =
d->threadData->eventLoops.pop();
219 Q_ASSERT_X(eventLoop ==
this,
"QEventLoop::exec()",
"internal error");
222 --
d->threadData->loopLevel;
230 QEventLoop *eventLoop =
d->threadData->eventLoops.pop();
231 Q_ASSERT_X(eventLoop ==
this,
"QEventLoop::exec()",
"internal error");
234 --
d->threadData->loopLevel;
236 return d->returnCode;
258 if (!
d->threadData->eventDispatcher)
268 if (flags & DeferredDeletion)
291 if (!
d->threadData->eventDispatcher)
294 d->returnCode = returnCode;
296 d->threadData->eventDispatcher->interrupt();
320 if (!
d->threadData->eventDispatcher)
322 d->threadData->eventDispatcher->wakeUp();
#define QT_END_NAMESPACE
This macro expands to.
void unlock()
Unlocks this mutex locker.
The QObject class is the base class of all Qt objects.
The QElapsedTimer class provides a fast way to calculate elapsed times.
static QObjectPrivate * get(QObject *o)
qint64 elapsed() const
Returns the number of milliseconds since this QElapsedTimer was last started.
void relock()
Relocks an unlocked mutex locker.
#define QT_BEGIN_NAMESPACE
This macro expands to.
The QEventLoop class provides a means of entering and leaving an event loop.
void quit()
Tells the event loop to exit normally.
Q_CORE_EXPORT void qWarning(const char *,...)
~QEventLoop()
Destroys the event loop object.
static void sendPostedEvents()
The QCoreApplication class provides an event loop for console Qt applications.
#define Q_ASSERT_X(cond, where, what)
void exit(int returnCode=0)
Tells the event loop to exit with a return code.
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
#define Q_DECLARE_PUBLIC(Class)
bool isRunning() const
Returns true if the event loop is running; otherwise returns false.
QEventLoop(QObject *parent=0)
Constructs an event loop object with the given parent.
static QCoreApplication * instance()
Returns a pointer to the application's QCoreApplication (or QApplication) instance.
removePostedEvents
Removes all events of the given eventType that were posted using postEvent() for receiver.
QThread * thread() const
Returns the thread in which the object lives.
static void createEventDispatcher(QThreadData *data)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
void start()
Starts this timer.
bool processEvents(ProcessEventsFlags flags=AllEvents)
Processes pending events that match flags until there are no more events to process.
int exec(ProcessEventsFlags flags=AllEvents)
Enters the main event loop and waits until exit() is called.
void wakeUp()
Wakes up the event loop.