summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/qeventdispatcher_glib.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/corelib/kernel/qeventdispatcher_glib.cpp b/src/corelib/kernel/qeventdispatcher_glib.cpp
index 59c937362b..86f6b0b4aa 100644
--- a/src/corelib/kernel/qeventdispatcher_glib.cpp
+++ b/src/corelib/kernel/qeventdispatcher_glib.cpp
@@ -62,6 +62,7 @@ struct GSocketNotifierSource
{
GSource source;
QList<GPollFDWithQSocketNotifier *> pollfds;
+ int activeNotifierPos;
};
static gboolean socketNotifierSourcePrepare(GSource *, gint *timeout)
@@ -100,8 +101,9 @@ static gboolean socketNotifierSourceDispatch(GSource *source, GSourceFunc, gpoin
QEvent event(QEvent::SockAct);
GSocketNotifierSource *src = reinterpret_cast<GSocketNotifierSource *>(source);
- for (int i = 0; i < src->pollfds.count(); ++i) {
- GPollFDWithQSocketNotifier *p = src->pollfds.at(i);
+ for (src->activeNotifierPos = 0; src->activeNotifierPos < src->pollfds.count();
+ ++src->activeNotifierPos) {
+ GPollFDWithQSocketNotifier *p = src->pollfds.at(src->activeNotifierPos);
if ((p->pollfd.revents & p->pollfd.events) != 0)
QCoreApplication::sendEvent(p->socketNotifier, &event);
@@ -501,6 +503,10 @@ void QEventDispatcherGlib::unregisterSocketNotifier(QSocketNotifier *notifier)
d->socketNotifierSource->pollfds.removeAt(i);
delete p;
+ // Keep a position in the list for the next item.
+ if (i <= d->socketNotifierSource->activeNotifierPos)
+ --d->socketNotifierSource->activeNotifierPos;
+
return;
}
}