76 #include "qplatformdefs.h" 77 #include "private/qt_mac_p.h" 84 #include "private/qwidget_p.h" 85 #include "private/qthread_p.h" 86 #include "private/qapplication_p.h" 88 #include <private/qcocoaapplication_mac_p.h> 89 #include "private/qt_cocoa_helpers_mac_p.h" 113 #ifndef QT_MAC_USE_COCOA 114 return reinterpret_cast<CFRunLoopRef
>(
const_cast<void *
>(GetCFRunLoopFromEventLoop(GetMainEventLoop())));
116 return CFRunLoopGetMain();
136 if (tmr == 0 || tmr->
pending ==
true)
157 if (timerId < 1 || interval < 0 || !obj) {
158 qWarning(
"QEventDispatcherMac::registerTimer: invalid arguments");
161 qWarning(
"QObject::startTimer: timers cannot be started from another thread");
173 CFAbsoluteTime fireDate = CFAbsoluteTimeGetCurrent();
174 CFTimeInterval cfinterval =
qMax(CFTimeInterval(interval) / 1000, 0.0000001);
175 fireDate += cfinterval;
177 CFRunLoopTimerContext
info = { 0, (
void *)timerId, 0, 0, 0 };
178 t->
runLoopTimer = CFRunLoopTimerCreate(0, fireDate, cfinterval, 0, 0,
181 qFatal(
"QEventDispatcherMac::registerTimer: Cannot create timer");
189 if (identifier < 1) {
190 qWarning(
"QEventDispatcherMac::unregisterTimer: invalid argument");
193 qWarning(
"QObject::killTimer: timers cannot be stopped from another thread");
217 qWarning(
"QEventDispatcherMac::unregisterTimers: invalid argument");
220 qWarning(
"QObject::killTimers: timers cannot be stopped from another thread");
228 if (timerInfo->
obj != obj) {
246 qWarning(
"QEventDispatcherMac:registeredTimers: invalid argument");
255 if (t->
obj ==
object)
266 const void *,
void *
info) {
269 int nativeSocket = CFSocketGetNative(s);
278 if (callbackType == kCFSocketReadCallBack) {
281 }
else if (callbackType == kCFSocketWriteCallBack) {
292 CFRunLoopSourceRef loopSource = CFSocketCreateRunLoopSource(kCFAllocatorDefault, socket, 0);
296 CFRunLoopAddSource(
mainRunLoop(), loopSource, kCFRunLoopCommonModes);
306 CFRunLoopRemoveSource(
mainRunLoop(), runloop, kCFRunLoopCommonModes);
307 CFSocketDisableCallBacks(socket, kCFSocketReadCallBack);
308 CFSocketDisableCallBacks(socket, kCFSocketWriteCallBack);
309 CFRunLoopSourceInvalidate(runloop);
322 int nativeSocket = notifier->
socket();
325 if (nativeSocket < 0 || nativeSocket > FD_SETSIZE) {
326 qWarning(
"QSocketNotifier: Internal error");
328 }
else if (notifier->
thread() != thread()
330 qWarning(
"QSocketNotifier: socket notifiers cannot be enabled from another thread");
338 qWarning(
"QSocketNotifier::Exception is not supported on Mac OS X");
349 const int callbackTypes = kCFSocketReadCallBack | kCFSocketWriteCallBack;
350 CFSocketContext context = {0,
d, 0, 0, 0};
352 if (CFSocketIsValid(socketInfo->
socket) ==
false) {
353 qWarning(
"QEventDispatcherMac::registerSocketNotifier: Failed to create CFSocket");
357 CFOptionFlags flags = CFSocketGetSocketFlags(socketInfo->
socket);
358 flags |= kCFSocketAutomaticallyReenableWriteCallBack;
359 flags &= ~kCFSocketCloseOnInvalidate;
360 CFSocketSetSocketFlags(socketInfo->
socket, flags);
364 qWarning(
"QEventDispatcherMac::registerSocketNotifier: Failed to add CFSocket to runloop");
365 CFSocketInvalidate(socketInfo->
socket);
366 CFRelease(socketInfo->
socket);
373 CFSocketDisableCallBacks(socketInfo->
socket, kCFSocketReadCallBack);
374 CFSocketDisableCallBacks(socketInfo->
socket, kCFSocketWriteCallBack);
376 d->macSockets.insert(nativeSocket, socketInfo);
383 CFSocketEnableCallBacks(socketInfo->
socket, kCFSocketReadCallBack);
387 CFSocketEnableCallBacks(socketInfo->
socket, kCFSocketWriteCallBack);
399 int nativeSocket = notifier->
socket();
402 if (nativeSocket < 0 || nativeSocket > FD_SETSIZE) {
403 qWarning(
"QSocketNotifier: Internal error");
406 qWarning(
"QSocketNotifier: socket notifiers cannot be disabled from another thread");
414 qWarning(
"QSocketNotifier::Exception is not supported on Mac OS X");
419 qWarning(
"QEventDispatcherMac::unregisterSocketNotifier: Tried to unregister a not registered notifier");
427 CFSocketDisableCallBacks(socketInfo->
socket, kCFSocketReadCallBack);
431 CFSocketDisableCallBacks(socketInfo->
socket, kCFSocketWriteCallBack);
436 if (CFSocketIsValid(socketInfo->
socket))
438 CFRunLoopSourceInvalidate(socketInfo->
runloop);
439 CFRelease(socketInfo->
runloop);
440 CFSocketInvalidate(socketInfo->
socket);
441 CFRelease(socketInfo->
socket);
443 d->macSockets.remove(nativeSocket);
456 #ifndef QT_MAC_USE_COCOA 457 if(pt && SendEventToWindow(event, pt) != eventNotHandledErr)
459 return !SendEventToEventTarget(event, GetEventDispatcherTarget());
460 #else // QT_MAC_USE_COCOA 462 [pt sendEvent:
event];
464 [NSApp sendEvent:
event];
469 #ifdef QT_MAC_USE_COCOA 470 static bool IsMouseOrKeyEvent( NSEvent*
event )
474 switch( [event
type] )
476 case NSLeftMouseDown:
478 case NSRightMouseDown:
481 case NSLeftMouseDragged:
482 case NSRightMouseDragged:
491 case NSTabletProximity:
492 case NSOtherMouseDown:
494 case NSOtherMouseDragged:
495 #ifndef QT_NO_GESTURES 496 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 497 case NSEventTypeGesture:
498 case NSEventTypeMagnify:
499 case NSEventTypeSwipe:
500 case NSEventTypeRotate:
501 case NSEventTypeBeginGesture:
502 case NSEventTypeEndGesture:
504 #endif // QT_NO_GESTURES 517 #ifndef QT_MAC_USE_COCOA 518 while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 1.0e20,
true) == kCFRunLoopRunTimedOut) ;
524 NSEvent*
event = [NSApp nextEventMatchingMask:NSAnyEventMask
525 untilDate:[NSDate distantFuture]
526 inMode:NSDefaultRunLoopMode
529 [NSApp postEvent:
event atStart:YES];
533 #ifdef QT_MAC_USE_COCOA 534 static inline void qt_mac_waitForMoreModalSessionEvents()
540 NSEvent*
event = [NSApp nextEventMatchingMask:NSAnyEventMask
541 untilDate:[NSDate distantFuture]
542 inMode:NSModalPanelRunLoopMode
545 [NSApp postEvent:
event atStart:YES];
552 d->interrupt =
false;
554 #ifdef QT_MAC_USE_COCOA 555 bool interruptLater =
false;
556 QtMacInterruptDispatcherHelp::cancelInterruptLater();
570 #ifdef QT_MAC_USE_COCOA 575 if (!excludeUserEvents) {
576 while (!
d->queuedUserInputEvents.isEmpty()) {
577 event =
static_cast<NSEvent *
>(
d->queuedUserInputEvents.takeFirst());
578 if (!filterEvent(
event)) {
593 const bool canExec_3rdParty =
d->nsAppRunCalledByQt || ![NSApp isRunning];
594 const bool canExec_Qt = !excludeUserEvents &&
597 if (canExec_Qt && canExec_3rdParty) {
601 if (NSModalSession session =
d->currentModalSession()) {
603 while ([NSApp runModalSession:session] == NSRunContinuesResponse && !
d->interrupt)
604 qt_mac_waitForMoreModalSessionEvents();
606 if (!
d->interrupt && session ==
d->currentModalSessionCached) {
610 d->temporarilyStopAllModalSessions();
613 d->nsAppRunCalledByQt =
true;
621 d->ensureNSAppInitialized();
622 if (NSModalSession session =
d->currentModalSession()) {
624 if (!excludeUserEvents) {
628 qt_mac_waitForMoreModalSessionEvents();
629 NSInteger
status = [NSApp runModalSession:session];
630 if (status != NSRunContinuesResponse && session ==
d->currentModalSessionCached) {
634 d->temporarilyStopAllModalSessions();
641 event = [NSApp nextEventMatchingMask:NSAnyEventMask
643 inMode:NSModalPanelRunLoopMode
647 if (IsMouseOrKeyEvent(
event)) {
649 d->queuedUserInputEvents.append(
event);
655 }
while (!
d->interrupt &&
event != nil);
658 event = [NSApp nextEventMatchingMask:NSAnyEventMask
660 inMode:NSDefaultRunLoopMode
664 if (flags & QEventLoop::ExcludeUserInputEvents) {
665 if (IsMouseOrKeyEvent(
event)) {
667 d->queuedUserInputEvents.append(
event);
674 }
while (!
d->interrupt &&
event != nil);
686 interruptLater =
true;
691 if (!(flags & QEventLoop::ExcludeUserInputEvents)
692 && !
d->queuedUserInputEvents.isEmpty()) {
694 event =
static_cast<EventRef>(
d->queuedUserInputEvents.takeFirst());
696 OSStatus err = ReceiveNextEvent(0,0, kEventDurationNoWait,
true, &event);
700 if (flags & QEventLoop::ExcludeUserInputEvents) {
701 UInt32 ekind = GetEventKind(event),
702 eclass = GetEventClass(event);
708 case kEventClassMouse:
709 case kEventClassKeyboard:
710 d->queuedUserInputEvents.append(event);
719 }
while(!
d->interrupt && GetNumEventsInQueue(GetMainEventQueue()) > 0);
723 bool canWait = (
d->threadData->canWait
747 #ifdef QT_MAC_USE_COCOA 749 QtMacInterruptDispatcherHelp::interruptLater();
758 d->serialNumber.ref();
759 CFRunLoopSourceSignal(
d->postedEventsSource);
767 for(
int i = 0; i < tlws.
size(); i++) {
782 #ifdef QT_MAC_USE_COCOA 784 bool QEventDispatcherMacPrivate::currentExecIsNSAppRun =
false;
785 bool QEventDispatcherMacPrivate::nsAppRunCalledByQt =
false;
786 bool QEventDispatcherMacPrivate::cleanupModalSessionsNeeded =
false;
787 NSModalSession QEventDispatcherMacPrivate::currentModalSessionCached = 0;
789 void QEventDispatcherMacPrivate::ensureNSAppInitialized()
801 if (nsAppRunCalledByQt || [NSApp isRunning])
803 nsAppRunCalledByQt =
true;
809 void QEventDispatcherMacPrivate::temporarilyStopAllModalSessions()
820 int stackSize = cocoaModalSessionStack.size();
821 for (
int i=0; i<stackSize; ++i) {
822 QCocoaModalSessionInfo &
info = cocoaModalSessionStack[i];
824 [NSApp endModalSession:info.session];
828 currentModalSessionCached = 0;
831 NSModalSession QEventDispatcherMacPrivate::currentModalSession()
835 if (currentModalSessionCached)
836 return currentModalSessionCached;
838 if (cocoaModalSessionStack.isEmpty())
841 int sessionCount = cocoaModalSessionStack.size();
842 for (
int i=0; i<sessionCount; ++i) {
843 QCocoaModalSessionInfo &
info = cocoaModalSessionStack[i];
854 ensureNSAppInitialized();
857 [(NSWindow*) info.nswindow retain];
858 int levelBeforeEnterModal = [window level];
859 info.session = [NSApp beginModalSessionForWindow:window];
862 if (levelBeforeEnterModal > [window level])
863 [window setLevel:levelBeforeEnterModal];
865 currentModalSessionCached = info.session;
866 cleanupModalSessionsNeeded =
false;
868 return currentModalSessionCached;
871 static void setChildrenWorksWhenModal(
QWidget *
widget,
bool worksWhenModal)
876 for (
int i=0; i<dialogs.
size(); ++i){
878 if (window && [window isKindOfClass:[NSPanel
class]]) {
879 [
static_cast<NSPanel *
>(
window) setWorksWhenModal:worksWhenModal];
880 if (worksWhenModal && [window isVisible]){
881 [window orderFront:
window];
887 void QEventDispatcherMacPrivate::updateChildrenWorksWhenModal()
893 int size = cocoaModalSessionStack.size();
895 if (
QWidget *prevModal = cocoaModalSessionStack[size-1].widget)
896 setChildrenWorksWhenModal(prevModal,
true);
898 if (
QWidget *prevModal = cocoaModalSessionStack[size-2].widget)
899 setChildrenWorksWhenModal(prevModal,
false);
904 void QEventDispatcherMacPrivate::cleanupModalSessions()
914 int stackSize = cocoaModalSessionStack.size();
916 for (
int i=stackSize-1; i>=0; --i) {
917 QCocoaModalSessionInfo &
info = cocoaModalSessionStack[i];
923 currentModalSessionCached = info.session;
926 cocoaModalSessionStack.remove(i);
927 currentModalSessionCached = 0;
929 [NSApp endModalSession:info.session];
930 [(NSWindow *)info.nswindow release];
934 updateChildrenWorksWhenModal();
935 cleanupModalSessionsNeeded =
false;
938 void QEventDispatcherMacPrivate::beginModalSession(
QWidget *widget)
948 cocoaModalSessionStack.push(info);
949 updateChildrenWorksWhenModal();
950 currentModalSessionCached = 0;
953 void QEventDispatcherMacPrivate::endModalSession(
QWidget *widget)
960 int stackSize = cocoaModalSessionStack.size();
961 for (
int i=stackSize-1; i>=0; --i) {
962 QCocoaModalSessionInfo &
info = cocoaModalSessionStack[i];
963 if (info.widget == widget) {
965 if (i == stackSize-1) {
968 currentModalSessionCached = 0;
969 cleanupModalSessionsNeeded =
true;
986 CFRunLoopSourceContext context;
987 bzero(&context,
sizeof(CFRunLoopSourceContext));
991 d->postedEventsSource = CFRunLoopSourceCreate(0, 0, &context);
993 CFRunLoopAddSource(
mainRunLoop(),
d->postedEventsSource, kCFRunLoopCommonModes);
995 CFRunLoopObserverContext observerContext;
996 bzero(&observerContext,
sizeof(CFRunLoopObserverContext));
997 observerContext.info =
this;
998 d->waitingObserver = CFRunLoopObserverCreate(kCFAllocatorDefault,
999 kCFRunLoopBeforeWaiting | kCFRunLoopAfterWaiting,
1003 CFRunLoopAddObserver(
mainRunLoop(),
d->waitingObserver, kCFRunLoopCommonModes);
1009 CFRunLoopObserverContext firstTimeObserverContext;
1010 bzero(&firstTimeObserverContext,
sizeof(CFRunLoopObserverContext));
1011 firstTimeObserverContext.info =
d;
1012 d->firstTimeObserver = CFRunLoopObserverCreate(kCFAllocatorDefault,
1017 &firstTimeObserverContext);
1018 CFRunLoopAddObserver(
mainRunLoop(),
d->firstTimeObserver, kCFRunLoopCommonModes);
1022 CFRunLoopActivity activity,
void *
info)
1024 if (activity == kCFRunLoopBeforeWaiting)
1032 return info1 == info2;
1037 if (blockSendPostedEvents) {
1046 #ifdef QT_MAC_USE_COCOA 1047 if (d->cleanupModalSessionsNeeded)
1048 d->cleanupModalSessions();
1052 #ifdef QT_MAC_USE_COCOA 1053 if (d->currentExecIsNSAppRun) {
1058 if (d->currentModalSessionCached)
1059 d->temporarilyStopAllModalSessions();
1061 d->cancelWaitForMoreEvents();
1074 CFRunLoopActivity activity,
1079 #ifdef QT_MAC_USE_COCOA 1080 QApplicationPrivate::qt_initAfterNSAppStarted();
1082 processPostedEvents(static_cast<QEventDispatcherMacPrivate *>(info), blockSendPostedEvents);
1087 processPostedEvents(static_cast<QEventDispatcherMacPrivate *>(info), blockSendPostedEvents);
1090 #ifdef QT_MAC_USE_COCOA 1091 void QEventDispatcherMacPrivate::cancelWaitForMoreEvents()
1096 [NSApp postEvent:[NSEvent otherEventWithType:NSApplicationDefined
location:NSZeroPoint
1097 modifierFlags:0 timestamp:0. windowNumber:0 context:0
1105 d->interrupt =
true;
1108 #ifndef QT_MAC_USE_COCOA 1118 d->cancelWaitForMoreEvents();
1127 while (it != QEventDispatcherMacPrivate::macTimerHash.
end()) {
1136 QEventDispatcherMacPrivate::macTimerHash.
clear();
1141 if (CFSocketIsValid(socketInfo->
socket)) {
1143 CFRunLoopSourceInvalidate(socketInfo->
runloop);
1144 CFRelease(socketInfo->
runloop);
1145 CFSocketInvalidate(socketInfo->
socket);
1146 CFRelease(socketInfo->
socket);
1149 CFRunLoopRemoveSource(
mainRunLoop(),
d->postedEventsSource, kCFRunLoopCommonModes);
1150 CFRelease(
d->postedEventsSource);
1152 CFRunLoopObserverInvalidate(
d->waitingObserver);
1153 CFRelease(
d->waitingObserver);
1155 CFRunLoopObserverInvalidate(
d->firstTimeObserver);
1156 CFRelease(
d->firstTimeObserver);
1159 #ifdef QT_MAC_USE_COCOA 1161 QtMacInterruptDispatcherHelp* QtMacInterruptDispatcherHelp::instance = 0;
1163 QtMacInterruptDispatcherHelp::QtMacInterruptDispatcherHelp() : cancelled(
false)
1174 QtMacInterruptDispatcherHelp::~QtMacInterruptDispatcherHelp()
1182 void QtMacInterruptDispatcherHelp::cancelInterruptLater()
1191 void QtMacInterruptDispatcherHelp::interruptLater()
1193 cancelInterruptLater();
1194 instance =
new QtMacInterruptDispatcherHelp;
static bool qt_mac_send_event(QEventLoop::ProcessEventsFlags, OSEventRef event, OSWindowRef pt)
static void sendPostedEvents(QObject *receiver, int event_type, QThreadData *data)
OSWindowRef qt_mac_window_for(const QWidget *)
static MacTimerHash macTimerHash
The QHash::const_iterator class provides an STL-style const iterator for QHash and QMultiHash...
virtual void interrupt()=0
Interrupts event dispatching; i.
static mach_timebase_info_data_t info
#define QT_END_NAMESPACE
This macro expands to.
QPointer< QWidget > widget
void clear()
Removes all items from the hash.
#define it(className, varName)
The QDialog class is the base class of dialog windows.
CFRunLoopTimerRef runLoopTimer
static void postEvent(QObject *receiver, QEvent *event)
Adds the event event, with the object receiver as the receiver of the event, to an event queue and re...
void qt_mac_remove_socket_from_runloop(const CFSocketRef socket, CFRunLoopSourceRef runloop)
static QAbstractEventDispatcher * instance(QThread *thread=0)
Returns a pointer to the event dispatcher object for the specified thread.
bool processEvents(QEventLoop::ProcessEventsFlags flags)
Processes pending events that match flags until there are no more events to process.
static void qt_mac_waitForMoreEvents()
void macWindowFlush(void *window)
void qt_event_request_select(QEventDispatcherMac *)
static LibLoadStatus status
The QStack class is a template class that provides a stack.
T & value() const
Returns a modifiable reference to the current item's value.
bool hasPendingEvents()
Returns true if there is an event waiting; otherwise returns false.
T take(const Key &key)
Removes the item with the key from the hash and returns the value associated with it...
The QHash class is a template class that provides a hash-table-based dictionary.
bool qt_sendSpontaneousEvent(QObject *, QEvent *)
The QObject class is the base class of all Qt objects.
static QObjectPrivate * get(QObject *o)
static void processPostedEvents(QEventDispatcherMacPrivate *const d, const bool blockSendPostedEvents)
const T value(const Key &key) const
Returns the value associated with the key.
Type type() const
Returns the socket event type specified to the constructor.
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
The QSocketNotifier class provides support for monitoring activity on a file descriptor.
void registerTimer(int timerId, int interval, QObject *object)
Register a timer with the specified timerId and interval for the given object.
static void postedEventsSourcePerformCallback(void *info)
static QThread * currentThread()
Returns a pointer to a QThread which manages the currently executing thread.
#define QT_BEGIN_NAMESPACE
This macro expands to.
void awake()
This signal is emitted after the event loop returns from a function that could block.
static bool blockSendPostedEvents
bool unregisterTimers(QObject *object)
Unregisters all the timers associated with the given object.
CFRunLoopSourceRef qt_mac_add_socket_to_runloop(const CFSocketRef socket)
The QEventLoop class provides a means of entering and leaving an event loop.
QList< TimerInfo > registeredTimers(QObject *object) const
Returns a list of registered timers for object.
void qt_event_request_updates()
const T & at(int i) const
Returns the item at index position i in the list.
CFRunLoopSourceRef runloop
const T & value() const
Returns the current item's value.
Q_CORE_EXPORT void qWarning(const char *,...)
static void activateTimer(CFRunLoopTimerRef, void *info)
static void waitingObserverCallback(CFRunLoopObserverRef observer, CFRunLoopActivity activity, void *info)
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
Q_CORE_EXPORT uint qGlobalPostedEventsCount()
static QWidgetList topLevelWidgets()
Returns a list of the top-level widgets (windows) in the application.
QEventDispatcherMac(QObject *parent=0)
struct OpaqueEventRef * EventRef
void wakeUp()
Wakes up the event loop.
void qt_event_request_timer(MacTimerInfo *)
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the hash.
Q_CORE_EXPORT void qFatal(const char *,...)
static CFRunLoopRef mainRunLoop()
void aboutToBlock()
This signal is emitted before the event loop calls a function that could block.
The QTimerEvent class contains parameters that describe a timer event.
bool unregisterTimer(int timerId)
Unregisters the timer with the given timerId.
QEventDispatcherMacPrivate()
void unregisterSocketNotifier(QSocketNotifier *notifier)
Unregisters notifier from the event dispatcher.
static QTestResult::TestLocation location
void qt_mac_socket_callback(CFSocketRef s, CFSocketCallBackType callbackType, CFDataRef, const void *, void *info)
const UInt32 kEventClassQt
The QHash::iterator class provides an STL-style non-const iterator for QHash and QMultiHash.
int size() const
Returns the number of items in the list.
if(void) toggleToolbarShown
iterator begin()
Returns an STL-style iterator pointing to the first item in the hash.
static void releaseTimerId(int id)
CFRunLoopSourceRef postedEventsSource
void interrupt()
Interrupts event dispatching; i.
#define QT_USE_NAMESPACE
This macro expands to using QT_NAMESPACE if QT_NAMESPACE is defined and nothing otherwise.
QFuture< T > run(Function function,...)
void registerSocketNotifier(QSocketNotifier *notifier)
Registers notifier with the event loop.
bool qt_mac_is_macsheet(const QWidget *)
QThread * thread() const
Returns the thread in which the object lives.
static const KeyPair *const end
The QEvent class is the base class of all event classes.
MacTimerInfo * qt_event_get_timer(EventRef)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
static void firstLoopEntry(CFRunLoopObserverRef ref, CFRunLoopActivity activity, void *info)
static Boolean postedEventSourceEqualCallback(const void *info1, const void *info2)
void deleteLater()
Schedules this object for deletion.
QList< T > findChildren(const QString &aName=QString()) const
Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects.
iterator erase(iterator it)
Removes the (key, value) pair associated with the iterator pos from the hash, and returns an iterator...
void flush()
Flushes the event queue.
The QAbstractEventDispatcher class provides an interface to manage Qt's event queue.
int socket() const
Returns the socket identifier specified to the constructor.
The QList class is a template class that provides lists.
#define forever
This macro is provided for convenience for writing infinite loops.