summaryrefslogtreecommitdiff
path: root/source/l/qt/qt.glib-honor-ExcludeSocketNotifiers-flag.diff
blob: 6949bbfef31a28d641006d3d2046a12606d1e932 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
Author: Jan-Marek Glogowski <glogow@fbihome.de>
Date:   Thu Mar 06 18:44:43 2014 +0100

    Honor QEventLoop::ExcludeSocketNotifiers in glib event loop.
    
    Implements QEventLoop::ExcludeSocketNotifiers in the same way 
    QEventLoop::X11ExcludeTimers is already implemented for the glib
    event loop.

--- qt4-x11-4.8.1.orig/src/corelib/kernel/qeventdispatcher_glib.cpp
+++ qt4-x11-4.8.1/src/corelib/kernel/qeventdispatcher_glib.cpp
@@ -65,6 +65,7 @@ struct GPollFDWithQSocketNotifier
 struct GSocketNotifierSource
 {
     GSource source;
+    QEventLoop::ProcessEventsFlags processEventsFlags;
     QList<GPollFDWithQSocketNotifier *> pollfds;
 };
 
@@ -80,6 +81,9 @@ static gboolean socketNotifierSourceChec
     GSocketNotifierSource *src = reinterpret_cast<GSocketNotifierSource *>(source);
 
     bool pending = false;
+    if (src->processEventsFlags & QEventLoop::ExcludeSocketNotifiers)
+        return pending;
+
     for (int i = 0; !pending && i < src->pollfds.count(); ++i) {
         GPollFDWithQSocketNotifier *p = src->pollfds.at(i);
 
@@ -103,6 +107,9 @@ static gboolean socketNotifierSourceDisp
     QEvent event(QEvent::SockAct);
 
     GSocketNotifierSource *src = reinterpret_cast<GSocketNotifierSource *>(source);
+    if (src->processEventsFlags & QEventLoop::ExcludeSocketNotifiers)
+        return true;
+
     for (int i = 0; i < src->pollfds.count(); ++i) {
         GPollFDWithQSocketNotifier *p = src->pollfds.at(i);
 
@@ -330,6 +337,7 @@ QEventDispatcherGlibPrivate::QEventDispa
         reinterpret_cast<GSocketNotifierSource *>(g_source_new(&socketNotifierSourceFuncs,
                                                                sizeof(GSocketNotifierSource)));
     (void) new (&socketNotifierSource->pollfds) QList<GPollFDWithQSocketNotifier *>();
+    socketNotifierSource->processEventsFlags = QEventLoop::AllEvents;
     g_source_set_can_recurse(&socketNotifierSource->source, true);
     g_source_attach(&socketNotifierSource->source, mainContext);
 
@@ -415,6 +423,7 @@ bool QEventDispatcherGlib::processEvents
     // tell postEventSourcePrepare() and timerSource about any new flags
     QEventLoop::ProcessEventsFlags savedFlags = d->timerSource->processEventsFlags;
     d->timerSource->processEventsFlags = flags;
+    d->socketNotifierSource->processEventsFlags = flags;
 
     if (!(flags & QEventLoop::EventLoopExec)) {
         // force timers to be sent at normal priority
@@ -426,6 +435,7 @@ bool QEventDispatcherGlib::processEvents
         result = g_main_context_iteration(d->mainContext, canWait);
 
     d->timerSource->processEventsFlags = savedFlags;
+    d->socketNotifierSource->processEventsFlags = savedFlags;
 
     if (canWait)
         emit awake();