summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
authorThomas McGuire <thomas.mcguire.qnx@kdab.com>2012-10-09 14:07:28 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-10-13 05:51:19 +0200
commita1082dbc3f61f1747bd756f8fce2a54f558793ed (patch)
tree63f898057bee88533291776bcf173b7219822c8d /src/corelib/kernel
parentaea07d1f41b25c77c788dcd192eb70bda9835ae8 (diff)
Blackberry: Emit aboutToBlock() and awake() correctly in the dispatcher
On Blackberry, select() can actually temporarily wake up to process mative BPS events. Make sure to emit the aboutToBlock() and awake() signals in this situation accordingly. Change-Id: Ib324e702feb1cfebdc6926f80af9c92f291a2b94 Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com> Reviewed-by: Kevin Krammer <kevin.krammer@kdab.com> Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/qeventdispatcher_blackberry.cpp37
1 files changed, 30 insertions, 7 deletions
diff --git a/src/corelib/kernel/qeventdispatcher_blackberry.cpp b/src/corelib/kernel/qeventdispatcher_blackberry.cpp
index a553999121..33ca1023dd 100644
--- a/src/corelib/kernel/qeventdispatcher_blackberry.cpp
+++ b/src/corelib/kernel/qeventdispatcher_blackberry.cpp
@@ -295,14 +295,35 @@ int QEventDispatcherBlackberry::select(int nfds, fd_set *readfds, fd_set *writef
if (timeout)
timeout_bps = (timeout->tv_sec * 1000) + (timeout->tv_usec / 1000);
+ bool hasProcessedEventsOnce = false;
+ bps_event_t *event = 0;
+
// This loop exists such that we can drain the bps event queue of all native events
// more efficiently than if we were to return control to Qt after each event. This
// is important for handling touch events which can come in rapidly.
forever {
+ Q_ASSERT(!hasProcessedEventsOnce || event);
+
+ // Only emit the awake() and aboutToBlock() signals in the second iteration. For the first
+ // iteration, the UNIX event dispatcher will have taken care of that already.
+ if (hasProcessedEventsOnce)
+ emit awake();
+
+ // Filtering the native event should happen between the awake() and aboutToBlock() signal
+ // emissions. The calls awake() - filterNativeEvent() - aboutToBlock() - bps_get_event()
+ // need not to be interrupted by a break or return statement.
+ //
+ // Because of this, the native event is actually processed one loop iteration
+ // after it was retrieved with bps_get_event().
+ if (event)
+ filterNativeEvent(QByteArrayLiteral("bps_event_t"), static_cast<void*>(event), 0);
+
+ if (hasProcessedEventsOnce)
+ emit aboutToBlock();
+
// Wait for event or file to be ready
- bps_event_t *event = NULL;
+ event = 0;
const int result = bps_get_event(&event, timeout_bps);
-
if (result != BPS_SUCCESS)
qWarning("QEventDispatcherBlackberry::select: bps_get_event() failed");
@@ -314,14 +335,16 @@ int QEventDispatcherBlackberry::select(int nfds, fd_set *readfds, fd_set *writef
if (!event || bps_event_get_domain(event) == bpsIOReadyDomain)
break;
- // Any other events must be bps native events so we pass all such received
- // events through the native event filter chain
- filterNativeEvent(QByteArrayLiteral("bps_event_t"), static_cast<void*>(event), 0);
-
// Update the timeout. If this fails we have exceeded our alloted time or the system
// clock has changed time and we cannot calculate a new timeout so we bail out.
- if (!updateTimeout(&timeout_bps, startTime))
+ if (!updateTimeout(&timeout_bps, startTime)) {
+
+ // No more loop iteration, so we need to filter the event here.
+ filterNativeEvent(QByteArrayLiteral("bps_event_t"), static_cast<void*>(event), 0);
break;
+ }
+
+ hasProcessedEventsOnce = true;
}
// the number of bits set in the file sets