]>
Commit | Line | Data |
---|---|---|
a0850133 AM |
1 | Author: Jan-Marek Glogowski <glogow@fbihome.de> |
2 | Date: Thu Mar 06 18:44:43 2014 +0100 | |
85e3a333 | 3 | |
a0850133 AM |
4 | Honor QEventLoop::ExcludeSocketNotifiers in glib event loop. |
5 | ||
6 | Implements QEventLoop::ExcludeSocketNotifiers in the same way | |
7 | QEventLoop::X11ExcludeTimers is already implemented for the glib | |
8 | event loop. | |
85e3a333 | 9 | |
a0850133 AM |
10 | --- qt4-x11-4.8.1.orig/src/corelib/kernel/qeventdispatcher_glib.cpp |
11 | +++ qt4-x11-4.8.1/src/corelib/kernel/qeventdispatcher_glib.cpp | |
85e3a333 AM |
12 | @@ -65,6 +65,7 @@ struct GPollFDWithQSocketNotifier |
13 | struct GSocketNotifierSource | |
14 | { | |
15 | GSource source; | |
16 | + QEventLoop::ProcessEventsFlags processEventsFlags; | |
17 | QList<GPollFDWithQSocketNotifier *> pollfds; | |
18 | }; | |
19 | ||
a0850133 | 20 | @@ -80,6 +81,9 @@ static gboolean socketNotifierSourceChec |
85e3a333 AM |
21 | GSocketNotifierSource *src = reinterpret_cast<GSocketNotifierSource *>(source); |
22 | ||
23 | bool pending = false; | |
24 | + if (src->processEventsFlags & QEventLoop::ExcludeSocketNotifiers) | |
25 | + return pending; | |
26 | + | |
27 | for (int i = 0; !pending && i < src->pollfds.count(); ++i) { | |
28 | GPollFDWithQSocketNotifier *p = src->pollfds.at(i); | |
29 | ||
a0850133 | 30 | @@ -103,6 +107,9 @@ static gboolean socketNotifierSourceDisp |
85e3a333 AM |
31 | QEvent event(QEvent::SockAct); |
32 | ||
33 | GSocketNotifierSource *src = reinterpret_cast<GSocketNotifierSource *>(source); | |
34 | + if (src->processEventsFlags & QEventLoop::ExcludeSocketNotifiers) | |
35 | + return true; | |
36 | + | |
37 | for (int i = 0; i < src->pollfds.count(); ++i) { | |
38 | GPollFDWithQSocketNotifier *p = src->pollfds.at(i); | |
39 | ||
a0850133 | 40 | @@ -330,6 +337,7 @@ QEventDispatcherGlibPrivate::QEventDispa |
85e3a333 AM |
41 | reinterpret_cast<GSocketNotifierSource *>(g_source_new(&socketNotifierSourceFuncs, |
42 | sizeof(GSocketNotifierSource))); | |
43 | (void) new (&socketNotifierSource->pollfds) QList<GPollFDWithQSocketNotifier *>(); | |
44 | + socketNotifierSource->processEventsFlags = QEventLoop::AllEvents; | |
45 | g_source_set_can_recurse(&socketNotifierSource->source, true); | |
46 | g_source_attach(&socketNotifierSource->source, mainContext); | |
47 | ||
a0850133 | 48 | @@ -415,6 +423,7 @@ bool QEventDispatcherGlib::processEvents |
85e3a333 AM |
49 | // tell postEventSourcePrepare() and timerSource about any new flags |
50 | QEventLoop::ProcessEventsFlags savedFlags = d->timerSource->processEventsFlags; | |
51 | d->timerSource->processEventsFlags = flags; | |
52 | + d->socketNotifierSource->processEventsFlags = flags; | |
53 | ||
54 | if (!(flags & QEventLoop::EventLoopExec)) { | |
55 | // force timers to be sent at normal priority | |
a0850133 | 56 | @@ -426,6 +435,7 @@ bool QEventDispatcherGlib::processEvents |
85e3a333 AM |
57 | result = g_main_context_iteration(d->mainContext, canWait); |
58 | ||
59 | d->timerSource->processEventsFlags = savedFlags; | |
60 | + d->socketNotifierSource->processEventsFlags = savedFlags; | |
61 | ||
62 | if (canWait) | |
63 | emit awake(); |